結果

問題 No.1595 The Final Digit
ユーザー nautnaut
提出日時 2024-01-30 14:39:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 500 ms / 2,000 ms
コード長 285 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 11,776 KB
実行使用メモリ 42,856 KB
最終ジャッジ日時 2024-01-30 14:39:23
合計ジャッジ時間 13,005 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 445 ms
42,856 KB
testcase_01 AC 500 ms
42,856 KB
testcase_02 AC 444 ms
42,856 KB
testcase_03 AC 448 ms
42,856 KB
testcase_04 AC 460 ms
42,856 KB
testcase_05 AC 446 ms
42,856 KB
testcase_06 AC 470 ms
42,856 KB
testcase_07 AC 444 ms
42,856 KB
testcase_08 AC 442 ms
42,856 KB
testcase_09 AC 471 ms
42,856 KB
testcase_10 AC 483 ms
42,856 KB
testcase_11 AC 472 ms
42,856 KB
testcase_12 AC 448 ms
42,856 KB
testcase_13 AC 449 ms
42,856 KB
testcase_14 AC 470 ms
42,856 KB
testcase_15 AC 470 ms
42,856 KB
testcase_16 AC 473 ms
42,856 KB
testcase_17 AC 446 ms
42,856 KB
testcase_18 AC 448 ms
42,856 KB
testcase_19 AC 473 ms
42,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

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

K -= 3
A = np.array([[1, 1, 1], [1, 0, 0], [0, 1, 0]])
A % 10
l = np.array([r, q, p])

R = 0

for i in range(60):
    if (K >> i) & 1 == 1:
        l = A @ l
        l = l % 10

    A = A @ A
    A = A % 10

print(l[0] % 10)
0