結果

問題 No.658 テトラナッチ数列 Hard
コンテスト
ユーザー ts_
提出日時 2018-04-06 04:44:25
言語 C++11
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 12 ms / 2,000 ms
+ 814µs
コード長 591 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 858 ms
コンパイル使用メモリ 175,000 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-30 12:21:36
合計ジャッジ時間 2,103 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll t[100001];
int main(){
    t[0]=0,t[1]=0,t[2]=0,t[3]=1;
    int cnt=4;
    while(1){
        t[cnt]=(t[cnt-1]+t[cnt-2]+t[cnt-3]+t[cnt-4])%17;
        if(t[cnt]==1&&t[cnt-1]==0&&t[cnt-2]==0&&t[cnt-3]==0) break;
        ++cnt;
    }
    cnt-=3;
    //cout<<cnt<<endl;
    int q;
    ll n;
    cin>>q;
    rep(i,q){
        cin>>n;
        --n;
        cout<<t[n%cnt]<<endl;
    }
    return 0;
}
0