結果

問題 No.1595 The Final Digit
ユーザー m1k__m1k__
提出日時 2021-07-10 02:52:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 328 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 87,296 KB
実行使用メモリ 71,468 KB
最終ジャッジ日時 2023-09-14 14:56:31
合計ジャッジ時間 3,524 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,380 KB
testcase_01 AC 75 ms
71,444 KB
testcase_02 AC 71 ms
71,036 KB
testcase_03 AC 70 ms
71,336 KB
testcase_04 AC 68 ms
71,200 KB
testcase_05 AC 69 ms
71,380 KB
testcase_06 AC 70 ms
71,368 KB
testcase_07 AC 71 ms
71,260 KB
testcase_08 AC 72 ms
71,468 KB
testcase_09 AC 71 ms
71,220 KB
testcase_10 AC 72 ms
71,380 KB
testcase_11 AC 71 ms
71,416 KB
testcase_12 AC 71 ms
71,216 KB
testcase_13 AC 72 ms
71,144 KB
testcase_14 AC 72 ms
71,004 KB
testcase_15 AC 72 ms
71,372 KB
testcase_16 AC 70 ms
71,332 KB
testcase_17 AC 70 ms
71,432 KB
testcase_18 AC 70 ms
71,296 KB
testcase_19 AC 70 ms
71,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

P, Q, R, K = [int(x) for x in input().split()]
P %= 10; Q %= 10; R %= 10
p, q, r = P, Q, R
lst = [p, q, r]
for i in range(K-3):
    p,q,r = q,r,p+q+r
    p %= 10; q %= 10; r %= 10
    lst.append(r)
    if (p,q,r) == (P, Q, R):
        break
if len(lst) == K:
    print(lst[-1])
else:
    l = len(lst) - 3
    print(lst[(K-1)%l])
0