結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー pluto77pluto77
提出日時 2017-06-10 11:12:58
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 211 bytes
コンパイル時間 1,555 ms
コンパイル使用メモリ 77,092 KB
実行使用メモリ 116,172 KB
最終ジャッジ日時 2023-10-24 20:24:25
合計ジャッジ時間 3,371 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
76,008 KB
testcase_01 AC 67 ms
76,008 KB
testcase_02 AC 67 ms
76,008 KB
testcase_03 AC 68 ms
76,008 KB
testcase_04 AC 69 ms
76,008 KB
testcase_05 AC 69 ms
76,008 KB
testcase_06 AC 69 ms
76,008 KB
testcase_07 AC 69 ms
76,008 KB
testcase_08 AC 74 ms
77,076 KB
testcase_09 AC 73 ms
77,892 KB
testcase_10 AC 95 ms
84,924 KB
testcase_11 AC 195 ms
116,172 KB
testcase_12 AC 193 ms
116,172 KB
testcase_13 AC 194 ms
116,172 KB
testcase_14 AC 195 ms
116,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki_526

n,m=map(int,raw_input().split())

dp=[0 for i in xrange(n+1)]
def fib(x,y):
 if x==0:
  return 0
 dp[0]=0
 dp[1]=1
 for i in xrange(2,x+1):
  dp[i]=(dp[i-2]+dp[i-1])%y
 return dp[x]

print fib(n-1,m)
0