6/10に行われていたatcoder beginner contest 129のCにおいて、どうしてもRE(runtime error)が起きてしまいます。
26.txtのみがREになってしまいます。
def num_way(stair)の部分でエラーが出ているということまではわかるのですが、どこがいけないでしょうか。
以下がコードです。
from collections import deque def num_way(stair): memo = ["EMPTY"]*(stair+1) def _fib(stair): if stair == 1 or stair == 0: return 1 elif stair == 2: return 2 elif memo[stair] != "EMPTY": return memo[stair] else: memo[stair] = _fib(stair-1)+_fib(stair-2) return memo[stair] return _fib(stair) N, M = map(int,input().split()) a = deque([0]) path_poss = 1 ans = 1 for m in range(M): start = a.popleft() buff = int(input()) end = buff-1 if (end-start) <= -1: path_poss = 0 break a.append(buff+1) ans *= num_way(end-start) ans %= 1000000007 if path_poss == 0: print(0) else: start = a.popleft() end = N if(end-start) <= -1: path_poss = 0 if path_poss == 0: print(0) else: ans *= num_way(end-start) print(ans%1000000007)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/10 07:13