結果

問題 No.657 テトラナッチ数列 Easy
ユーザー dazydazy
提出日時 2018-05-04 15:28:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 550 bytes
コンパイル時間 1,220 ms
コンパイル使用メモリ 143,436 KB
実行使用メモリ 7,332 KB
最終ジャッジ日時 2023-09-10 09:37:33
合計ジャッジ時間 2,468 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 8 ms
7,036 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 9 ms
7,240 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 11 ms
7,332 KB
testcase_14 AC 12 ms
7,264 KB
testcase_15 AC 11 ms
7,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define fastcin {\
    cin.tie(0);\
    ios::sync_with_stdio(false);\
}
using namespace std;

int main() {
    fastcin;
    int q;
    cin >> q;
    int ta[1000001];
    ta[1] = ta[2] = ta[3] = 0, ta[4] = 1;
    int max = 4;
    for(int i = 0; i < q; i++) {
        int n;
        cin >> n;
        if(n > max) {
            for(int j = max+1; j < n+1; j++) {
                ta[j] = (ta[j-1] + ta[j-2] + ta[j-3] + ta[j-4])%17;
            }
            max = n;
        }
        cout << ta[n] << '\n';
    }
    return 0;
}
0