結果
| 問題 | No.1595 The Final Digit |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-05-27 10:15:35 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 507 ms / 2,000 ms |
| + 599µs | |
| コード長 | 510 bytes |
| 記録 | |
| コンパイル時間 | 667 ms |
| コンパイル使用メモリ | 21,412 KB |
| 実行使用メモリ | 34,872 KB |
| 最終ジャッジ日時 | 2026-07-11 02:14:52 |
| 合計ジャッジ時間 | 13,870 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
import numpy as np
def mat_power(m: np.ndarray, n: int, mod: int) -> np.ndarray:
if n == 0: return np.identity(len(m), dtype=object)
res = mat_power(m, n // 2, mod)
res = res @ res % mod
if n % 2 == 1:
res = res @ m % mod
return res
MOD = 10
P, Q, R, K = map(int, input().split())
P %= 10
Q %= 10
R %= 10
m = np.array(
[[1, 1, 1],
[1, 0, 0],
[0, 1, 0]])
a = np.array(
[[R],
[Q],
[P]])
t = mat_power(m, K-3, MOD) @ a
ans = t[0, 0] % MOD
print(ans)
norioc