結果

問題 No.1595 The Final Digit
ユーザー shotoyooshotoyoo
提出日時 2021-07-09 21:31:01
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 430 ms
使用メモリ 75,888 KB
最終ジャッジ日時 2023-02-01 22:15:41
合計ジャッジ時間 3,333 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 82 ms
75,804 KB
testcase_01 AC 81 ms
75,616 KB
testcase_02 AC 81 ms
75,696 KB
testcase_03 AC 81 ms
75,652 KB
testcase_04 AC 81 ms
75,888 KB
testcase_05 AC 83 ms
75,832 KB
testcase_06 AC 83 ms
75,676 KB
testcase_07 AC 83 ms
75,672 KB
testcase_08 AC 82 ms
75,612 KB
testcase_09 AC 82 ms
75,700 KB
testcase_10 AC 82 ms
75,612 KB
testcase_11 AC 82 ms
75,692 KB
testcase_12 AC 81 ms
75,736 KB
testcase_13 AC 83 ms
75,792 KB
testcase_14 AC 83 ms
75,816 KB
testcase_15 AC 83 ms
75,448 KB
testcase_16 AC 82 ms
75,684 KB
testcase_17 AC 84 ms
75,792 KB
testcase_18 AC 82 ms
75,696 KB
testcase_19 AC 81 ms
75,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


p,q,r,K = list(map(int, input().split()))
K -= 1
l = [p%10,q%10,r%10]
for i in range(10**6):
    l.append((l[-3]+l[-2]+l[-1])%10)
    if (l[0], l[1], l[2]) == (l[-3], l[-2], l[-1]):
        break
n = len(l) # (0,1,2) = (n-3, n-2, n-1)
k = K % (n-3)
ans = l[k]
print(ans)
0