题解 | #杨辉三角的变形#
杨辉三角的变形
https://www.nowcoder.com/practice/8ef655edf42d4e08b44be4d777edbf43
尴尬我也超时了,然后看了答案
import sys num = int(input()) # def get(lst,index): # try: # if index <0 or index >=len(lst): # return 0 # return lst[index] # except IndexError: # return 0 # r = -1 # lst = [] # for i in range(1,num+1): # if i==1: # lst = [1] # continue # _lst = [] # for j in range(i*2-1): # res = get(lst,j-2)+get(lst,j-1)+get(lst,j) # if i==num and res>0 and res%2==0: # r=j+1 # break # _lst.append(res) # lst = _lst # print(r) # -1 -1 2 3 2 4 2 3 2 4 lst = [2,4,2,3] if num<3: print(-1) else: print(lst[num%4-1])