結果

問題 No.658 テトラナッチ数列 Hard
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-03-06 23:25:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 286 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 11,816 KB
実行使用メモリ 11,408 KB
最終ジャッジ日時 2023-10-22 00:40:04
合計ジャッジ時間 1,672 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,796 KB
testcase_01 AC 34 ms
10,796 KB
testcase_02 AC 35 ms
10,796 KB
testcase_03 AC 35 ms
10,804 KB
testcase_04 AC 62 ms
11,408 KB
testcase_05 AC 62 ms
11,408 KB
testcase_06 AC 63 ms
11,408 KB
testcase_07 AC 62 ms
11,408 KB
testcase_08 AC 63 ms
11,356 KB
testcase_09 AC 63 ms
11,404 KB
testcase_10 AC 63 ms
11,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = [0,0,0,1]
k = 4
v = {}
while True:
    s = tuple(t[-4:])
    if s in v:
        break
    v[s] = k
    k += 1
    t.append(sum(s)%17)
b = v[s]
x = [int(input()) for _ in range(int(input()))]
for n in x:
    if n < b:
        print(t[n-1])
    else:
        print(t[b+(n-1-b)%(k-b)])
0