結果

問題 No.1595 The Final Digit
ユーザー Ain48803949Ain48803949
提出日時 2021-07-09 22:18:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 934 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 11,076 KB
最終ジャッジ日時 2023-09-14 09:33:52
合計ジャッジ時間 2,079 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
10,972 KB
testcase_01 AC 39 ms
10,972 KB
testcase_02 AC 38 ms
10,924 KB
testcase_03 AC 38 ms
11,076 KB
testcase_04 AC 38 ms
11,008 KB
testcase_05 AC 38 ms
11,072 KB
testcase_06 AC 38 ms
10,920 KB
testcase_07 AC 38 ms
10,980 KB
testcase_08 AC 38 ms
11,024 KB
testcase_09 AC 39 ms
10,924 KB
testcase_10 AC 38 ms
11,016 KB
testcase_11 AC 38 ms
10,928 KB
testcase_12 AC 38 ms
10,972 KB
testcase_13 AC 39 ms
10,924 KB
testcase_14 AC 38 ms
10,964 KB
testcase_15 AC 38 ms
10,904 KB
testcase_16 AC 38 ms
10,968 KB
testcase_17 AC 38 ms
11,016 KB
testcase_18 AC 37 ms
10,968 KB
testcase_19 AC 37 ms
10,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect,collections,copy,heapq,itertools,math,string,sys,queue,time,random
input = lambda: sys.stdin.readline().rstrip()
def I(): return input()
def IS(): return input().split()
def II(): return int(input())
def IIS(): return map(int,input().split())
def LIIS(): return list(map(int,input().split()))
def Base_n_to_10(X,n):
    out = 0
    for i in range(1,len(str(X))+1):
        out += int(X[-i])*(n**(i-1))
    return out#int out
def Base_10_to_n(X, n):
    if (X//n):
        return Base_10_to_n(X//n, n)+str(X%n)
    return str(X%n)
INF=10**18
MOD=10**9+7
sys.setrecursionlimit(10**8)
##############################################################################
p,q,r,k=IIS()
li=[0 for i in range(10**5)]
li[0]=p%10
li[1]=q%10
li[2]=r%10
i=3
while True:
    li[i]=(li[i-1]+li[i-2]+li[i-3])%10
    if li[i]==r%10 and li[i-1]==q%10 and li[i-2]==p%10:
        #i-2こ
        break
    i+=1
li=li[:i-2]
print(li[k%(i-2)-1])
0