結果

問題 No.673 カブトムシ
ユーザー brthyyjpbrthyyjp
提出日時 2022-02-14 12:39:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 690 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 86,720 KB
実行使用メモリ 71,176 KB
最終ジャッジ日時 2023-09-11 16:03:42
合計ジャッジ時間 3,083 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,072 KB
testcase_01 AC 65 ms
70,876 KB
testcase_02 AC 65 ms
70,984 KB
testcase_03 AC 68 ms
71,176 KB
testcase_04 AC 67 ms
70,632 KB
testcase_05 AC 66 ms
70,784 KB
testcase_06 AC 66 ms
70,800 KB
testcase_07 AC 66 ms
71,076 KB
testcase_08 AC 65 ms
71,100 KB
testcase_09 AC 66 ms
70,628 KB
testcase_10 AC 67 ms
70,872 KB
testcase_11 AC 66 ms
70,628 KB
testcase_12 AC 67 ms
70,796 KB
testcase_13 AC 65 ms
70,784 KB
testcase_14 AC 70 ms
70,984 KB
testcase_15 AC 68 ms
70,872 KB
testcase_16 AC 66 ms
70,780 KB
testcase_17 AC 65 ms
70,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# A*B
def mat_mul(A, B, mod):
    C = [[0]*len(B[0]) for i in range(len(A))]
    for i in range(len(A)):
        for k in range(len(B)):
            for j in range(len(B[0])):
                C[i][j] = (C[i][j] + A[i][k]*B[k][j])%mod
    return C

#A**n
def mat_pow(A, n, mod):
    B = [[0]*len(A) for i in range(len(A))]
    for i in range(len(A)):
        B[i][i] = 1
    while n > 0:
        if n & 1 == 1:
            B = mat_mul(A, B, mod)
        A = mat_mul(A, A, mod)
        n = n>>1
    return B

b, c, d = map(int, input().split())
mod = 10**9+7
A = [[c, b*c],[0, 1]]
x = [0, 1]
A = mat_pow(A, d, mod)
ans = 0
for j in range(2):
    ans += A[0][j]*x[j]
    ans %= mod
print(ans)
0