結果

問題 No.1595 The Final Digit
ユーザー prd_xxx
提出日時 2021-07-09 21:54:56
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 354 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-07-01 16:12:19
合計ジャッジ時間 1,472 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

p,q,r,K = map(int,input().split())

mem = [[[-1]*10 for _ in range(10)] for _ in range(10)]
a,b,c = p%10, q%10, r%10
mem[a][b][c] = 0
rev = {0:(a,b,c)}
i = 1
while 1:
    d = (a+b+c)%10
    a,b,c = b,c,d
    if mem[a][b][c] >= 0:
        r = i
        break
    mem[a][b][c] = i
    rev[i] = (a,b,c)
    i += 1

K -= 4
a,b,c = rev[K%r]
print((a+b+c)%10)
0