結果

問題 No.673 カブトムシ
ユーザー 👑 rin204rin204
提出日時 2022-03-25 05:07:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 692 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 82,584 KB
実行使用メモリ 56,260 KB
最終ジャッジ日時 2024-04-21 13:48:32
合計ジャッジ時間 1,906 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
54,668 KB
testcase_01 AC 36 ms
54,320 KB
testcase_02 AC 36 ms
54,464 KB
testcase_03 AC 36 ms
53,756 KB
testcase_04 AC 35 ms
53,696 KB
testcase_05 AC 37 ms
55,104 KB
testcase_06 AC 35 ms
54,684 KB
testcase_07 AC 35 ms
54,436 KB
testcase_08 AC 36 ms
54,516 KB
testcase_09 AC 36 ms
54,296 KB
testcase_10 AC 35 ms
53,812 KB
testcase_11 AC 39 ms
53,612 KB
testcase_12 AC 37 ms
56,260 KB
testcase_13 AC 36 ms
53,764 KB
testcase_14 AC 38 ms
54,308 KB
testcase_15 AC 37 ms
54,716 KB
testcase_16 AC 36 ms
54,936 KB
testcase_17 AC 36 ms
54,724 KB
権限があれば一括ダウンロードができます

ソースコード

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

b, c, d = map(int, input().split())
b %= MOD
c %= MOD
A = [[c, c], [0, 1]]
B = [0, b]
B = matpow(A, B, d)
print(B[0])

0