結果

問題 No.658 テトラナッチ数列 Hard
ユーザー 👑 obakyanobakyan
提出日時 2019-04-06 23:54:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 723 bytes
コンパイル時間 584 ms
コンパイル使用メモリ 74,120 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-07 11:40:11
合計ジャッジ時間 1,467 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iostream>
#include <iomanip>

int main(void)
{
    std::vector<int> t = { 0, 0, 0, 1 };
    bool matched = false;
    int i = 4;
    while (!matched) {
        t.push_back((t[i - 1] + t[i - 2] + t[i - 3] + t[i - 4]) % 17);
        if (t[i] == 1 && t[i - 1] == 0 && t[i - 2] == 0 && t[i - 3] == 0) {
            matched = true;
        }
        i = i + 1;
    }
    long long mod = i - 4;

    int n;
    long long a;
    std::cin >> n;
    for (i = 0; i < n; i++) {
        std::cin >> a;
        a--;
        a %= mod;
        std::cout << t[a] << std::endl;
    }
    return 0;
}
0