結果

問題 No.657 テトラナッチ数列 Easy
ユーザー lunnear
提出日時 2018-12-12 14:24:49
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 783 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 60,256 KB
実行使用メモリ 8,528 KB
最終ジャッジ日時 2024-09-25 03:34:01
合計ジャッジ時間 1,509 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#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