結果

問題 No.657 テトラナッチ数列 Easy
ユーザー CELICACELICA
提出日時 2020-08-18 22:28:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 692 bytes
コンパイル時間 1,782 ms
コンパイル使用メモリ 167,496 KB
実行使用メモリ 11,288 KB
最終ジャッジ日時 2024-04-20 07:57:59
合計ジャッジ時間 2,432 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 9 ms
10,444 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 9 ms
11,040 KB
testcase_09 AC 4 ms
6,944 KB
testcase_10 AC 4 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 5 ms
6,940 KB
testcase_13 AC 12 ms
11,112 KB
testcase_14 AC 12 ms
11,184 KB
testcase_15 AC 11 ms
11,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ul = unsigned long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int q;
    cin >> q;

    vector<long> vn(q);
    for (auto&& n : vn)
        cin >> n;

    auto it = max_element(vn.begin(), vn.end());
    long maxq = *it;

    vector<ll> t(maxq + 1, 0);
    if (maxq > 4)
    {
        t[1] = 0;
        t[2] = 0;
        t[3] = 0;
        t[4] = 1;

        for (long i = 5; i <= maxq; ++i)
            t[i] = (t[i - 1] + t[i - 2] + t[i - 3] + t[i - 4]) % 17;
    }
    else if (maxq == 4)
        t[4] = 1;

    for (const auto& n : vn)
        cout << t[n] << "\n";

    return 0;
}
0