結果

問題 No.1595 The Final Digit
ユーザー 👑 rin204rin204
提出日時 2021-07-09 21:57:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 555 bytes
コンパイル時間 623 ms
コンパイル使用メモリ 87,280 KB
実行使用メモリ 76,156 KB
最終ジャッジ日時 2023-09-14 08:54:12
合計ジャッジ時間 3,887 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
71,888 KB
testcase_01 AC 89 ms
71,636 KB
testcase_02 AC 89 ms
71,940 KB
testcase_03 AC 89 ms
71,704 KB
testcase_04 AC 91 ms
71,732 KB
testcase_05 AC 91 ms
71,768 KB
testcase_06 AC 97 ms
76,136 KB
testcase_07 AC 97 ms
76,076 KB
testcase_08 AC 91 ms
71,628 KB
testcase_09 AC 91 ms
71,836 KB
testcase_10 AC 90 ms
71,760 KB
testcase_11 AC 90 ms
71,644 KB
testcase_12 AC 91 ms
71,648 KB
testcase_13 AC 93 ms
71,672 KB
testcase_14 AC 96 ms
76,132 KB
testcase_15 AC 95 ms
75,928 KB
testcase_16 AC 96 ms
75,932 KB
testcase_17 AC 89 ms
71,472 KB
testcase_18 AC 91 ms
71,632 KB
testcase_19 AC 96 ms
76,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import deepcopy

p, q, r, K = map(int, input().split())

B = [r, q, p]
A = [[1, 1, 1], 
     [1, 0, 0],
     [0, 1, 0]]

K -= 3
while K:
    if K & 1:
        C = [0, 0, 0]
        for i in range(3):
            for j in range(3):
                C[i] += A[i][j] * B[j]
            C[i] %= 10
        B = C.copy()
    C = [[0] * 3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            for k in range(3):
                C[i][j] += A[i][k] * A[k][j]
            C[i][j] %= 10
    A = deepcopy(C)
    K >>= 1
print(B[0])
0