結果

問題 No.657 テトラナッチ数列 Easy
ユーザー aka_riceaka_rice
提出日時 2018-03-03 11:53:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 1,560 ms
コンパイル使用メモリ 164,020 KB
実行使用メモリ 7,592 KB
最終ジャッジ日時 2023-09-06 01:56:20
合計ジャッジ時間 2,827 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
7,440 KB
testcase_01 AC 8 ms
7,488 KB
testcase_02 AC 8 ms
7,428 KB
testcase_03 AC 8 ms
7,592 KB
testcase_04 AC 8 ms
7,500 KB
testcase_05 AC 22 ms
7,472 KB
testcase_06 AC 8 ms
7,496 KB
testcase_07 AC 8 ms
7,352 KB
testcase_08 AC 8 ms
7,412 KB
testcase_09 AC 24 ms
7,432 KB
testcase_10 AC 24 ms
7,464 KB
testcase_11 AC 24 ms
7,436 KB
testcase_12 AC 24 ms
7,412 KB
testcase_13 AC 25 ms
7,436 KB
testcase_14 AC 25 ms
7,488 KB
testcase_15 AC 25 ms
7,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define pout(n)  printf ("%d\n", n)
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define BIT(bit,a,n) for (int bit = a;bit < (1<<n);bit++) // {0, 1, ..., n-1} の部分集合の全探索 // n番目のフラグが立っている状態は (1<<n)
const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };
#define MAX_N (int)2e5+20
typedef long long ll;
using namespace std;

int q;
int main(){
    int t[1000001];
    t[0] = 0;
    t[1] = 0;
    t[2] = 0;
    t[3] = 1;
    rep(i,4,1000001){
        t[i] = (t[i-1]+t[i-2]+t[i-3]+t[i-4])%17;
    }
    scanf("%d",&q);
    rep(i,0,q){
        int n;
        cin >> n;
        printf("%d\n",t[n-1]);        
    }
}
0