結果
問題 |
No.1595 The Final Digit
|
ユーザー |
|
提出日時 | 2021-11-20 01:58:36 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 736 bytes |
コンパイル時間 | 183 ms |
コンパイル使用メモリ | 82,104 KB |
実行使用メモリ | 67,576 KB |
最終ジャッジ日時 | 2025-01-02 06:48:54 |
合計ジャッジ時間 | 2,504 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 17 |
ソースコード
#!/usr/bin/env python3 # from typing import * import sys import io import numpy as np import math import collections import decimal import itertools import bisect import heapq def input(): return sys.stdin.readline()[:-1] # sys.setrecursionlimit(1000000) # _INPUT = """86 91 20 1001 # """ # sys.stdin = io.StringIO(_INPUT) INF = 10**10 def solve(p, q, r, K): N = K-3 A = np.matrix([[1, 1, 1], [1, 0, 0], [0, 1, 0]]) M = A An = np.identity(M.shape[0], dtype=object) while N: if N & 1: An = np.mod(An * M, 10) M = np.mod(M * M, 10) N >>= 1 v = An * np.array([[r], [q], [p]]) return v[0, 0] % 10 p, q, r, K = map(int, input().split()) print(solve(p, q, r, K))