前兩筆測資有通過~
但第三筆被killed,請問該怎麼修改,謝謝
import sys
for line in sys.stdin:
if line.split():
n=int(line)
X={1,2}
cache=[0 for _ in range(n+1)]
cache[0]=1
def staircase(n,X):
for i in range(n+1):
cache[i] += (sum(cache[i-x] for x in X if i-x>0))%1000000007
cache[i] += 1 if i in X else 0
return cache[-1]
print(staircase(n,X))