結果

問題 No.1595 The Final Digit
ユーザー ShirotsumeShirotsume
提出日時 2021-07-09 23:52:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 384 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,736 KB
実行使用メモリ 8,432 KB
最終ジャッジ日時 2023-09-14 11:19:12
合計ジャッジ時間 1,828 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,288 KB
testcase_01 AC 18 ms
8,372 KB
testcase_02 AC 16 ms
8,336 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 16 ms
8,252 KB
testcase_06 AC 17 ms
8,312 KB
testcase_07 AC 16 ms
8,320 KB
testcase_08 AC 16 ms
8,308 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 15 ms
8,340 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 16 ms
8,312 KB
testcase_18 AC 16 ms
8,312 KB
testcase_19 AC 16 ms
8,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

a = [-1] * 10000

a[0] = p % 10
a[1] = q % 10
a[2] = r % 10

for i in range(3, 100):
    x = (a[i - 1] + a[i - 2] + a[i - 3]) % 10
    if x in a[4:]:
        start = a.index(x)
        end = i
        a[i] = x
        break
    
    a[i] = x
if k < end:
    print(a[k - 1])
    exit()
ind = (k - 1 - start) % (end - start) + start

print(a[ind])
0