結果

問題 No.658 テトラナッチ数列 Hard
ユーザー lunnearlunnear
提出日時 2018-12-12 14:43:46
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 859 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 61,304 KB
実行使用メモリ 813,352 KB
最終ジャッジ日時 2023-10-25 08:25:14
合計ジャッジ時間 3,376 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    
    
    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++)
    {
        long long n;
        std::cin >> n;
        
        if(n > list.size())
        {
            for(long long 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] << "\n";
    }
    
    return 0;
}
0