P1249 最大乘积

打暴力找规律,都是连续自然数去掉一个

n=int(input())
a=[]
cnt=0
i=2
tot=0
ans=1
while tot<=n:
    tot+=i
    cnt+=1
    a.append(i)
    i+=1
for j in range(0,cnt):
    if(a[j]!=(tot-n)):
        print(a[j],end=" ")
        ans*=a[j]
print()
print(ans)

 

posted @ 2019-08-01 16:52  WeiAR  阅读(275)  评论(0编辑  收藏  举报