結果

問題 No.1595 The Final Digit
ユーザー w0mbatw0mbat
提出日時 2021-07-09 21:39:56
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 502 bytes
コンパイル時間 1,174 ms
使用メモリ 79,840 KB
最終ジャッジ日時 2023-02-01 22:35:26
合計ジャッジ時間 3,682 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 75 ms
75,816 KB
testcase_01 AC 77 ms
75,772 KB
testcase_02 AC 77 ms
75,752 KB
testcase_03 AC 77 ms
75,552 KB
testcase_04 AC 75 ms
75,728 KB
testcase_05 AC 78 ms
75,728 KB
testcase_06 AC 77 ms
75,848 KB
testcase_07 AC 77 ms
75,672 KB
testcase_08 AC 75 ms
75,824 KB
testcase_09 AC 78 ms
79,840 KB
testcase_10 AC 75 ms
75,828 KB
testcase_11 AC 78 ms
79,572 KB
testcase_12 AC 77 ms
79,576 KB
testcase_13 AC 75 ms
75,724 KB
testcase_14 AC 77 ms
79,576 KB
testcase_15 AC 79 ms
79,816 KB
testcase_16 AC 76 ms
75,768 KB
testcase_17 AC 76 ms
75,636 KB
testcase_18 AC 77 ms
75,812 KB
testcase_19 AC 76 ms
75,528 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