結果

問題 No.657 テトラナッチ数列 Easy
ユーザー tokizotokizo
提出日時 2019-03-09 11:08:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 1,503 ms
コンパイル使用メモリ 166,884 KB
実行使用メモリ 11,088 KB
最終ジャッジ日時 2023-09-05 19:48:44
合計ジャッジ時間 2,531 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 9 ms
10,256 KB
testcase_05 AC 14 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 10 ms
10,828 KB
testcase_09 AC 15 ms
4,384 KB
testcase_10 AC 16 ms
4,376 KB
testcase_11 AC 16 ms
4,376 KB
testcase_12 AC 16 ms
4,376 KB
testcase_13 AC 23 ms
11,088 KB
testcase_14 AC 24 ms
11,024 KB
testcase_15 AC 24 ms
10,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

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

    int n, maxi = -1e9;
    cin >> n;
    vector<long long> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
        maxi = max((long long)maxi, A[i]);
    }

    vector<long long> T(maxi + 1);
    T[4] = 1;
    for(int i = 5; i <= maxi; i++){
        T[i] += (T[i - 1] + T[i - 2] + T[i - 3] + T[i - 4]) % 17;
    }

    for(int i = 0; i < n; i++){
        cout << T[A[i]] % 17 << endl;
    }

    return 0;
}
0