結果

問題 No.657 テトラナッチ数列 Easy
ユーザー nukachanukacha
提出日時 2018-04-09 15:11:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 663 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 65,088 KB
実行使用メモリ 9,016 KB
最終ジャッジ日時 2023-09-09 03:26:07
合計ジャッジ時間 7,334 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,504 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 6 ms
4,376 KB
testcase_05 AC 15 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 7 ms
4,376 KB
testcase_09 AC 40 ms
4,380 KB
testcase_10 AC 260 ms
4,380 KB
testcase_11 AC 257 ms
4,380 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

int main() {
    using namespace std;
    int q;
    cin >> q;
    int n[q];
    for (int i = 0; i < q; i++) {
        cin >> n[i];
    }
    for (int i = 0; i < q; i++) {
        int r = 0;
        if (n[i] < 4) {
            r = 0;
        } else if (n[i] == 4) {
            r = 1;
        } else {
            int p[4] = {1, 0, 0, 0};
            for (int j = 0; j < n[i] - 4; j++) {
                int tmp = p[0] + p[1] + p[2] + p[3];
                p[3] = p[2];
                p[2] = p[1];
                p[1] = p[0];
                p[0] = tmp % 17;
            }
            r = p[0];
        }
        cout << r << endl;
    }

}
0