結果
問題 |
No.3045 反復重み付き累積和
|
ユーザー |
![]() |
提出日時 | 2025-03-31 17:19:04 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 622 bytes |
コンパイル時間 | 382 ms |
コンパイル使用メモリ | 82,468 KB |
実行使用メモリ | 60,160 KB |
最終ジャッジ日時 | 2025-03-31 17:19:53 |
合計ジャッジ時間 | 3,584 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 41 |
ソースコード
def pisano_period(m): if m == 1: return 1 previous, current = 0, 1 period = 0 for _ in range(m * 6): previous, current = current, (previous + current) % m period += 1 if previous == 0 and current == 1: return period return period # Fallback, theoretically shouldn't reach here def fib_mod_r(r, m): if r == 0: return 0 a, b = 0, 1 for _ in range(r - 1): a, b = b, (a + b) % m return b n, m = map(int, input().split()) if m == 1: print(0) else: period = pisano_period(m) r = n % period print(fib_mod_r(r, m))