結果
問題 | No.891 隣接3項間の漸化式 |
ユーザー |
![]() |
提出日時 | 2020-12-13 18:29:59 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 637 bytes |
コンパイル時間 | 215 ms |
コンパイル使用メモリ | 81,980 KB |
実行使用メモリ | 84,696 KB |
最終ジャッジ日時 | 2024-09-19 23:45:11 |
合計ジャッジ時間 | 4,290 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 TLE * 1 -- * 28 |
ソースコード
def mat_mul(A, B): size = len(A) res = [[0] * size for _ in range(size)] for i in range(size): for k in range(size): for j in range(size): res[i][j] += A[i][k] * B[k][j] res[i][j] %= mod return res def mat_pow(A, n): size = len(A) res = [[0] * size for _ in range(size)] for i in range(size): res[i][i] = 1 while n: if n & 1: res = mat_mul(res, A) A = mat_mul(A, A) n >>= 1 return res mod = 10 ** 9 + 7 a, b, n = map(int, input().split()) A = [[a, b], [1, 0]] A = mat_pow(A, n-1) print(A[0][0] % mod)