結果

問題 No.891 隣接3項間の漸化式
ユーザー 👑 rin204rin204
提出日時 2022-03-25 18:06:13
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 680 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 208,608 KB
最終ジャッジ日時 2024-04-22 03:42:56
合計ジャッジ時間 4,752 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
58,752 KB
testcase_01 AC 47 ms
53,376 KB
testcase_02 AC 46 ms
53,376 KB
testcase_03 AC 47 ms
53,632 KB
testcase_04 AC 49 ms
53,376 KB
testcase_05 AC 47 ms
53,760 KB
testcase_06 AC 47 ms
53,888 KB
testcase_07 AC 48 ms
54,016 KB
testcase_08 AC 51 ms
53,760 KB
testcase_09 AC 54 ms
53,632 KB
testcase_10 AC 53 ms
53,760 KB
testcase_11 AC 47 ms
53,376 KB
testcase_12 AC 47 ms
53,760 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import deepcopy
MOD = 10 ** 9 + 7

def matpow(A, B, w):
    l = len(A)
    while w:
        if w & 1:
            C = [0] * l
            for i in range(l):
                for j in range(l):
                    C[i] += A[i][j] * B[j]
                    C[i] %= MOD
            B = C.copy()
        C = [[0] * l for _ in range(l)]
        for i in range(l):
            for j in range(l):
                for k in range(l):
                    C[i][j] += A[i][k] * A[k][j]
                    C[i][j] %= MOD
        A = deepcopy(C)
        w >>= 1
    return B
    
a, b, n = map(int, input().split())
A = [[a, b], [1, 0]]
B = [1, 0]
B = matpow(A, B, n - 1)
print(B[0])
0