代码
- 超时代码,只有40分
N = int(input())
if N==1:
print(1)
exit()
else:
n = 3 #行数
lst = list()
lst.append([1, 1])
sum = 3 # 第几位,最终输出
while 1:
alst = list()
j = 0 # 该行的第几个数字
while j <= n-1:
if j==0 or j==n-1:
alst.append(1)
sum += 1
else:
x = lst[0][j-1]+lst[0][j]
alst.append(x)
sum += 1
if x==N:
print(sum)
exit()
j += 1
# temp = alst
lst.append(alst)
lst.pop(0)
# alst.clear()
n += 1