結果

問題 No.534 フィボナッチフィボナッチ数
ユーザー pekempeypekempey
提出日時 2017-06-23 22:51:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 354 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 82,960 KB
実行使用メモリ 54,144 KB
最終ジャッジ日時 2024-04-14 06:03:40
合計ジャッジ時間 3,048 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,508 KB
testcase_01 AC 38 ms
52,548 KB
testcase_02 AC 37 ms
52,980 KB
testcase_03 AC 37 ms
53,200 KB
testcase_04 AC 36 ms
52,916 KB
testcase_05 AC 36 ms
52,588 KB
testcase_06 AC 37 ms
52,260 KB
testcase_07 AC 37 ms
52,448 KB
testcase_08 AC 36 ms
52,832 KB
testcase_09 AC 37 ms
52,332 KB
testcase_10 AC 36 ms
51,828 KB
testcase_11 AC 36 ms
52,572 KB
testcase_12 AC 36 ms
53,060 KB
testcase_13 AC 36 ms
52,392 KB
testcase_14 AC 37 ms
52,396 KB
testcase_15 AC 37 ms
52,592 KB
testcase_16 AC 37 ms
52,148 KB
testcase_17 AC 37 ms
52,808 KB
testcase_18 AC 37 ms
53,084 KB
testcase_19 AC 36 ms
52,596 KB
testcase_20 AC 36 ms
53,056 KB
testcase_21 AC 36 ms
52,936 KB
testcase_22 AC 37 ms
52,636 KB
testcase_23 AC 37 ms
52,340 KB
testcase_24 AC 37 ms
53,932 KB
testcase_25 AC 37 ms
53,292 KB
testcase_26 AC 37 ms
52,992 KB
testcase_27 AC 37 ms
52,880 KB
testcase_28 AC 37 ms
52,156 KB
testcase_29 AC 37 ms
53,024 KB
testcase_30 AC 37 ms
53,344 KB
testcase_31 AC 37 ms
53,372 KB
testcase_32 AC 37 ms
52,588 KB
testcase_33 AC 37 ms
52,480 KB
testcase_34 AC 37 ms
53,120 KB
testcase_35 AC 37 ms
54,144 KB
testcase_36 AC 37 ms
53,020 KB
testcase_37 AC 37 ms
52,596 KB
testcase_38 AC 37 ms
52,760 KB
testcase_39 AC 37 ms
53,136 KB
testcase_40 AC 37 ms
52,272 KB
testcase_41 AC 36 ms
53,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(n, mod, a=0, b=1, c=1, a0=0, a1=1):
    if n == 0: return a0
    na0 = (a * a0 + b * a1) % mod if n % 2 == 1 else a0
    na1 = (b * a0 + c * a1) % mod if n % 2 == 1 else a1
    return f(n // 2, mod, (a * a + b * b) % mod, b * (a + c) % mod, (b * b + c * c) % mod, na0, na1)

n = int(input())

MOD = 10 ** 9 + 7

print(f(f(n, MOD * MOD - 1), MOD))
0