結果

問題 No.1595 The Final Digit
ユーザー w0mbatw0mbat
提出日時 2021-07-09 21:39:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 502 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 86,984 KB
実行使用メモリ 75,164 KB
最終ジャッジ日時 2023-09-14 08:09:46
合計ジャッジ時間 2,986 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,320 KB
testcase_01 AC 73 ms
71,160 KB
testcase_02 AC 73 ms
71,388 KB
testcase_03 AC 72 ms
71,348 KB
testcase_04 AC 73 ms
71,152 KB
testcase_05 AC 72 ms
71,356 KB
testcase_06 AC 72 ms
71,284 KB
testcase_07 AC 72 ms
71,340 KB
testcase_08 AC 72 ms
71,088 KB
testcase_09 AC 78 ms
74,832 KB
testcase_10 AC 72 ms
71,232 KB
testcase_11 AC 73 ms
75,164 KB
testcase_12 AC 73 ms
75,080 KB
testcase_13 AC 71 ms
71,492 KB
testcase_14 AC 74 ms
74,872 KB
testcase_15 AC 75 ms
74,828 KB
testcase_16 AC 73 ms
71,236 KB
testcase_17 AC 71 ms
71,588 KB
testcase_18 AC 72 ms
71,236 KB
testcase_19 AC 71 ms
71,304 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