結果
| 問題 |
No.891 隣接3項間の漸化式
|
| コンテスト | |
| ユーザー |
brthyyjp
|
| 提出日時 | 2021-01-02 11:46:03 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 503 bytes |
| コンパイル時間 | 135 ms |
| コンパイル使用メモリ | 82,416 KB |
| 実行使用メモリ | 66,988 KB |
| 最終ジャッジ日時 | 2024-10-12 01:36:02 |
| 合計ジャッジ時間 | 3,633 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 39 |
ソースコード
import numpy as np
#A**n
def mat_pow(A, n, mod):
size = len(A)
res = np.eye(size, dtype=np.object)
while n > 0:
if n & 1 == 1:
res = res @ A
res %= mod
A = A @ A
A %= mod
n = n>>1
return res
# https://yukicoder.me/problems/no/891
a, b, n = map(int, input().split())
x = np.array([[1], [0]])
mod = 10**9+7
if n <= 1:
print(x[1-n][0]%mod)
exit()
A = np.array([[a, b], [1, 0]])
A = mat_pow(A, n-1, mod)
print((A@x)[0][0])
brthyyjp