結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー iad_2889
提出日時 2019-05-17 01:57:00
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 233 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-09-17 05:45:42
合計ジャッジ時間 1,352 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 2 RE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

def calc_fibonacci_number(n):
    n-=1
    c = 1 / 5 ** 0.5
    a = ((1 + 5 ** 0.5) / 2) ** n
    b = ((1 - 5 ** 0.5) / 2) ** n
    return int(c * (a - b))

N,M = map(int,input().split())
ans = calc_fibonacci_number(N) % M
print(ans)
0