將一個整數拆分為幾個數的和,求這幾個數的最大值
阿新 • • 發佈:2019-02-17
#coding=utf-8
import pdb
def split_int( num ):
#pdb.set_trace()
if num < 2:
result = 0
elif num == 2:
result == 1
elif num == 3:
result == 2
else:
dp = []
dp.append(1)
dp.append(2)
dp.append(3)
for i in range(2, num):
current_max = -1
for j in range(i//2):
if dp[j] * dp[i - j] > current_max:
current_max = dp[j] * dp[i - j]
dp.append(current_max)
result = dp[-1]
return result
if __name__ == "__main__":
print (split_int(int(input())))