結果

問題 No.1595 The Final Digit
ユーザー tcltktcltk
提出日時 2021-11-20 01:58:36
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 736 bytes
コンパイル時間 1,997 ms
コンパイル使用メモリ 86,264 KB
実行使用メモリ 78,716 KB
最終ジャッジ日時 2023-08-30 15:21:17
合計ジャッジ時間 7,214 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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))
0