結果

問題 No.658 テトラナッチ数列 Hard
ユーザー maimai
提出日時 2018-03-02 22:32:33
言語 Ruby
(3.3.0)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 259 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 11,468 KB
実行使用メモリ 15,880 KB
最終ジャッジ日時 2023-09-03 23:15:21
合計ジャッジ時間 2,266 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
15,348 KB
testcase_01 AC 87 ms
15,420 KB
testcase_02 AC 87 ms
15,540 KB
testcase_03 AC 86 ms
15,240 KB
testcase_04 AC 129 ms
15,792 KB
testcase_05 AC 129 ms
15,756 KB
testcase_06 AC 129 ms
15,708 KB
testcase_07 AC 128 ms
15,800 KB
testcase_08 AC 130 ms
15,688 KB
testcase_09 AC 131 ms
15,764 KB
testcase_10 AC 129 ms
15,880 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

NMAX = 1e6.to_i

t = [0,0,0,1]
freq = nil

NMAX.times do |i|
    t.push (t[-1]+t[-2]+t[-3]+t[-4])%17
    if [t[-4],t[-3],t[-2],t[-1]] == [0,0,0,1]
        freq = i+1
        break
    end
end

gets.to_i.times do |i|
    n = (gets.to_i-1)%freq
    p t[n]
end

0