forked from Gitlink/forgeplus
23 lines
630 B
Python
23 lines
630 B
Python
dividing_number = {0: 0}
|
|
times = 0
|
|
|
|
|
|
def split(number, index):
|
|
global times
|
|
for i in range(1, number + 1):
|
|
if i >= dividing_number[index - 1]:
|
|
dividing_number[index] = i
|
|
number_rest = number - i
|
|
if number_rest == 0:
|
|
for j in range(1, index):
|
|
print(str(dividing_number[j]) + '+', end='')
|
|
print(str(dividing_number[index]))
|
|
times = times + 1
|
|
else:
|
|
split(number_rest, index + 1)
|
|
|
|
|
|
n = int(input("请输入一个整数:"))
|
|
split(n, 1)
|
|
print("所以该整数的划分数为:%d" % times)
|