結果

問題 No.1595 The Final Digit
ユーザー ki_ato_mo
提出日時 2021-07-10 19:38:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 462 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 58,752 KB
最終ジャッジ日時 2024-07-02 02:46:14
合計ジャッジ時間 1,901 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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