結果

問題 No.657 テトラナッチ数列 Easy
ユーザー tecchaxn
提出日時 2018-03-02 23:00:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 546 bytes
コンパイル時間 1,916 ms
コンパイル使用メモリ 158,576 KB
実行使用メモリ 11,304 KB
最終ジャッジ日時 2024-06-22 05:32:49
合計ジャッジ時間 2,377 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
#define INF 1e18
using namespace std;

//-----------------------------------------------------------------------

const int mod=17;

int t[1000005];

signed main()
{
    t[1]=t[2]=t[3]=0,t[4]=1;
    for(int i=5;i<=1000000;i++){
        t[i]=(t[i-1]+t[i-2]+t[i-3]+t[i-4])%mod;
    }
    
    int Q; cin>>Q;
    REP(i,Q){
        int n; cin>>n;
        cout<<t[n]<<endl;
    }
 
}
0