結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー iad_2889iad_2889
提出日時 2019-05-17 01:57:00
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 233 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 11,888 KB
実行使用メモリ 10,284 KB
最終ジャッジ日時 2023-10-17 07:08:13
合計ジャッジ時間 1,362 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,236 KB
testcase_01 AC 30 ms
10,236 KB
testcase_02 AC 29 ms
10,236 KB
testcase_03 AC 30 ms
10,236 KB
testcase_04 AC 28 ms
10,236 KB
testcase_05 AC 29 ms
10,236 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
権限があれば一括ダウンロードができます

ソースコード

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