結果

問題 No.1595 The Final Digit
ユーザー shotoyooshotoyoo
提出日時 2021-07-09 21:31:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 71,564 KB
最終ジャッジ日時 2023-09-14 07:52:55
合計ジャッジ時間 2,562 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,284 KB
testcase_01 AC 68 ms
71,320 KB
testcase_02 AC 68 ms
71,436 KB
testcase_03 AC 67 ms
71,308 KB
testcase_04 AC 68 ms
71,400 KB
testcase_05 AC 69 ms
71,396 KB
testcase_06 AC 67 ms
71,400 KB
testcase_07 AC 66 ms
71,520 KB
testcase_08 AC 66 ms
71,400 KB
testcase_09 AC 66 ms
71,292 KB
testcase_10 AC 66 ms
71,180 KB
testcase_11 AC 66 ms
71,420 KB
testcase_12 AC 68 ms
71,484 KB
testcase_13 AC 67 ms
71,376 KB
testcase_14 AC 66 ms
71,492 KB
testcase_15 AC 65 ms
71,564 KB
testcase_16 AC 65 ms
71,324 KB
testcase_17 AC 65 ms
71,484 KB
testcase_18 AC 68 ms
71,380 KB
testcase_19 AC 64 ms
71,244 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