結果

問題 No.657 テトラナッチ数列 Easy
ユーザー 👑 obakyanobakyan
提出日時 2019-03-29 23:58:17
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 366 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 5,120 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 16:52:57
合計ジャッジ時間 1,097 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 5 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 5 ms
5,376 KB
testcase_15 AC 5 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = {0, 0, 0, 1}
matched = false
i = 5
while(not matched) do
    t[i] = (t[i -1] + t[i - 2] + t[i - 3] + t[i - 4]) % 17
    if(t[i] == 1 and t[i - 1] == 0 and t[i - 2] == 0 and t[i - 3] == 0) then
        matched = true
    end
    i = i + 1
end
mod = i - 5

n = io.read("*n")
for i = 1, n do
    a = io.read("*n")
    a = a % mod
    print(t[(a - 1) % mod + 1])
end
0