結果

問題 No.1595 The Final Digit
ユーザー ki_ato_moki_ato_mo
提出日時 2021-07-10 19:38:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 462 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 76,324 KB
最終ジャッジ日時 2023-09-14 19:51:24
合計ジャッジ時間 3,330 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
71,660 KB
testcase_01 AC 89 ms
71,468 KB
testcase_02 AC 90 ms
71,632 KB
testcase_03 AC 93 ms
71,572 KB
testcase_04 AC 90 ms
71,744 KB
testcase_05 AC 91 ms
71,864 KB
testcase_06 AC 91 ms
71,640 KB
testcase_07 AC 92 ms
71,724 KB
testcase_08 AC 91 ms
71,716 KB
testcase_09 AC 90 ms
71,704 KB
testcase_10 AC 91 ms
71,636 KB
testcase_11 AC 92 ms
71,632 KB
testcase_12 AC 96 ms
76,324 KB
testcase_13 AC 91 ms
71,536 KB
testcase_14 AC 96 ms
76,104 KB
testcase_15 AC 97 ms
76,288 KB
testcase_16 AC 91 ms
71,788 KB
testcase_17 AC 91 ms
71,468 KB
testcase_18 AC 90 ms
71,584 KB
testcase_19 AC 91 ms
71,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
p, q, r, k = map(int, input().split())
s = (int(str(p)[-1]), int(str(q)[-1]), int(str(r)[-1]))
s_dic = defaultdict(int)
s_dic[s] = 1
loop_list = [s]
flg = 0
for i in range(k - 3):
    s = (s[1], s[2], int(str(sum(s))[-1]))
    if s_dic[s]:
        flg = 1
        break
    else:
        s_dic[s] = 1
        loop_list.append(s)
if flg:
    k -= 2
    k %= len(loop_list)
    print(loop_list[k - 1][-1])
else:
    print(s[-1])
0