結果

問題 No.657 テトラナッチ数列 Easy
ユーザー face4face4
提出日時 2018-04-30 14:43:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 406 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 65,028 KB
実行使用メモリ 7,408 KB
最終ジャッジ日時 2023-09-10 08:27:21
合計ジャッジ時間 1,844 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
7,212 KB
testcase_01 AC 11 ms
7,280 KB
testcase_02 AC 10 ms
7,212 KB
testcase_03 AC 10 ms
7,408 KB
testcase_04 AC 10 ms
7,404 KB
testcase_05 AC 24 ms
7,204 KB
testcase_06 AC 10 ms
7,260 KB
testcase_07 AC 10 ms
7,212 KB
testcase_08 AC 10 ms
7,204 KB
testcase_09 AC 25 ms
7,272 KB
testcase_10 AC 26 ms
7,232 KB
testcase_11 AC 26 ms
7,212 KB
testcase_12 AC 26 ms
7,264 KB
testcase_13 AC 27 ms
7,232 KB
testcase_14 AC 27 ms
7,352 KB
testcase_15 AC 27 ms
7,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

#define SIZE 1000001
int T[SIZE];

int main(){
    T[0] = 1; // 便宜上
    T[1] = T[2] = T[3] = 0;
    T[4] = 1;
    for(int i = 5; i < SIZE; i++){
        T[i] = (2*T[i-1] - T[i-5]) % 17;
        if(T[i] < 0)    T[i] += 17;
    }

    int q, n;
    cin >> q;

    for(int i = 0; i < q; i++){
        cin >> n;
        cout << T[n] << endl;
    }
    return 0;
}
0