結果

問題 No.1595 The Final Digit
ユーザー Eki1009Eki1009
提出日時 2021-07-09 21:35:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 76,468 KB
最終ジャッジ日時 2023-09-14 07:55:08
合計ジャッジ時間 2,671 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,220 KB
testcase_01 AC 69 ms
71,540 KB
testcase_02 AC 67 ms
71,468 KB
testcase_03 AC 69 ms
71,416 KB
testcase_04 AC 75 ms
75,668 KB
testcase_05 AC 74 ms
75,944 KB
testcase_06 AC 76 ms
76,396 KB
testcase_07 AC 75 ms
76,360 KB
testcase_08 AC 70 ms
71,344 KB
testcase_09 AC 69 ms
71,284 KB
testcase_10 AC 70 ms
71,216 KB
testcase_11 AC 70 ms
71,300 KB
testcase_12 AC 72 ms
71,276 KB
testcase_13 AC 71 ms
71,324 KB
testcase_14 AC 77 ms
76,468 KB
testcase_15 AC 79 ms
76,380 KB
testcase_16 AC 78 ms
76,096 KB
testcase_17 AC 71 ms
71,344 KB
testcase_18 AC 71 ms
71,348 KB
testcase_19 AC 77 ms
76,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10
p, q, r, k = map(int, input().split())
def mul(A, B):
    n = len(A)
    C = [[0]*n for _ in range(n)]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                C[i][j] += A[i][k] * B[k][j]
                C[i][j] %= mod
    return C
def mpow(A, n):
    if n == 1:
        return A
    if n%2:
        return mul(mpow(A, n-1), A)
    B = mpow(A, n//2)
    return mul(B, B)
A = [[0,1,0], [0,0,1], [1,1,1]]
B = mpow(A, k-3)
ans = B[-1][0]*p + B[-1][1]*q + B[-1][2]*r
ans %= mod
print(ans)
0