結果

問題 No.673 カブトムシ
ユーザー roarisroaris
提出日時 2020-06-24 04:25:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 816 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 71,540 KB
最終ジャッジ日時 2023-09-16 20:41:55
合計ジャッジ時間 3,388 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,476 KB
testcase_01 AC 75 ms
71,540 KB
testcase_02 AC 72 ms
71,540 KB
testcase_03 AC 73 ms
71,420 KB
testcase_04 AC 72 ms
71,272 KB
testcase_05 AC 73 ms
71,256 KB
testcase_06 AC 73 ms
71,444 KB
testcase_07 AC 73 ms
71,408 KB
testcase_08 AC 73 ms
71,444 KB
testcase_09 AC 73 ms
71,108 KB
testcase_10 AC 72 ms
70,980 KB
testcase_11 AC 73 ms
71,400 KB
testcase_12 AC 74 ms
71,244 KB
testcase_13 AC 71 ms
71,448 KB
testcase_14 AC 73 ms
71,284 KB
testcase_15 AC 73 ms
71,224 KB
testcase_16 AC 73 ms
71,160 KB
testcase_17 AC 75 ms
71,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

B, C, D = map(int, input().split())
MOD = 10**9+7
res = mat_mul(mat_pow([[C, B*C], [0, 1]], D-1), [[B*C], [1]])
print(res[0][0])
0