結果

問題 No.1595 The Final Digit
ユーザー w0mbatw0mbat
提出日時 2021-07-09 21:51:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 502 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 75,320 KB
最終ジャッジ日時 2023-09-14 08:43:36
合計ジャッジ時間 3,120 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,420 KB
testcase_01 AC 67 ms
71,420 KB
testcase_02 AC 66 ms
71,696 KB
testcase_03 AC 68 ms
71,404 KB
testcase_04 AC 68 ms
71,416 KB
testcase_05 AC 68 ms
71,300 KB
testcase_06 AC 69 ms
71,452 KB
testcase_07 AC 68 ms
71,292 KB
testcase_08 AC 68 ms
71,380 KB
testcase_09 AC 69 ms
75,164 KB
testcase_10 AC 66 ms
71,420 KB
testcase_11 AC 69 ms
75,184 KB
testcase_12 AC 70 ms
75,088 KB
testcase_13 AC 71 ms
71,540 KB
testcase_14 AC 69 ms
75,020 KB
testcase_15 AC 70 ms
75,320 KB
testcase_16 AC 70 ms
71,276 KB
testcase_17 AC 68 ms
71,468 KB
testcase_18 AC 69 ms
71,376 KB
testcase_19 AC 67 ms
71,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def main():
    input = sys.stdin.readline
    P, Q, R, K = map(int, input().split())
    S = set()
    L = list()
    for i in range(1000):
        if (P, Q, R) in S:
            j = L.index((P, Q, R))
            break
        S.add((P, Q, R))
        L.append((P, Q, R))
        P, Q, R = Q, R, (P + Q + R) % 10
    K -= 4
    if K <= i:
        print(sum(L[K]) % 10)
        return
    K -= i
    c = i - j
    K %= c
    print(sum(L[j + K]) % 10)

if __name__ == '__main__':
    main()
0