結果

問題 No.1595 The Final Digit
ユーザー stngstng
提出日時 2021-07-18 13:34:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 10,748 KB
実行使用メモリ 23,924 KB
最終ジャッジ日時 2023-09-22 15:27:56
合計ジャッジ時間 2,349 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
23,748 KB
testcase_01 AC 47 ms
23,772 KB
testcase_02 AC 43 ms
23,824 KB
testcase_03 AC 43 ms
23,924 KB
testcase_04 AC 43 ms
23,704 KB
testcase_05 AC 44 ms
23,884 KB
testcase_06 AC 42 ms
23,792 KB
testcase_07 AC 42 ms
23,816 KB
testcase_08 AC 41 ms
23,644 KB
testcase_09 AC 45 ms
23,768 KB
testcase_10 AC 42 ms
23,748 KB
testcase_11 AC 44 ms
23,888 KB
testcase_12 AC 42 ms
23,676 KB
testcase_13 AC 42 ms
23,872 KB
testcase_14 AC 42 ms
23,904 KB
testcase_15 AC 42 ms
23,852 KB
testcase_16 AC 43 ms
23,700 KB
testcase_17 AC 43 ms
23,704 KB
testcase_18 AC 43 ms
23,824 KB
testcase_19 AC 43 ms
23,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def srh(A,B,C):
    a[0],a[1],a[2] = A,B,C
    for i in range(3,len(a)):
        a[i] = a[i-1] + a[i-2] + a[i-3]
        a[i] %= 10
        if a[i-2] == a[0] and a[i-1] == a[1] and a[i] == a[2]:
            return i-2,a[:i-2]
            
"""
for i in range(3,len(a)):
    a[i] = a[i-1] + a[i-2] + a[i-3]
    a[i] %= 10
    if a[i-2] == a[0] and a[i-1] == a[1] and a[i] == a[2]:
        idx = i
        break
"""

K -= 4

a = [0]*10**6
f_idx , fst = srh(1,1,2)
a = [0]*10**6
s_idx , snd = srh(1,2,3)
a = [0]*10**6
t_idx , trd = srh(1,2,4)

ans = fst[K%f_idx]*p+snd[K%s_idx]*q+trd[K%t_idx]*r
print(ans%10)
0