結果

問題 No.657 テトラナッチ数列 Easy
コンテスト
ユーザー lunnear
提出日時 2018-12-12 14:24:49
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 30 ms / 2,000 ms
+ 228µs
コード長 783 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 432 ms
コンパイル使用メモリ 79,504 KB
実行使用メモリ 9,844 KB
最終ジャッジ日時 2026-10-29 17:50:05
合計ジャッジ時間 2,264 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>

int main()
{
    int q;
    std::cin >> q;
    
    std::vector<int> list;
    int t1 = 0, t2 = 0, t3 = 0, t4 = 1;
    list.push_back(0);
    list.push_back(0);
    list.push_back(0);
    list.push_back(1);
    
    
    for(int i = 0; i < q; i++)
    {
        int n;
        std::cin >> n;
        
        if(n > list.size())
        {
            for(int j = list.size(); j < n; j++)
            {
                int t = t1 + t2 + t3 + t4;
                t %= 17;
                
                list.push_back(t);
                
                t1 = t2;
                t2 = t3;
                t3 = t4;
                t4 = t;
            }
        }
        
        std::cout << list[n - 1] << std::endl;
    }
    
    return 0;
}
0