結果
問題 | No.534 フィボナッチフィボナッチ数 |
ユーザー |
|
提出日時 | 2017-06-23 23:28:15 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 628 bytes |
コンパイル時間 | 345 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-10-03 03:43:20 |
合計ジャッジ時間 | 2,601 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 42 |
ソースコード
p = 10**9 + 7 #10**9 + 7 ''' a, b = 1, 0 i = 0 while(True): a, b = (a + b) % p, a i += 1 if (i % 10000 == 0):print(i) if (a == 1 and b == 0):break if (a == 0 and b == 0):break print(i, a, b) ''' # fib(cycle)%p = 0 # fib(cycle + 1)%p = 1 cycle = 2000000016 def fib(n, mod): a, b, d = 1, 1, 0 ta, tb, tc, td = 1, 0, 0, 1 while n: if n & 1: ta, tb, tc, td = (a*ta+b*tb)%mod, (a*tb+b*td)%mod, (b*ta+d*tc)%mod, (b*tb+d*td)%mod a, b, d = (a*a+b*b)%mod, (b*(a+d))%mod, (b*b+d*d)%mod n >>= 1 return tc n = int(input()) x = fib(n, cycle) y = fib(x, p) print(y)