結果

問題 No.658 テトラナッチ数列 Hard
ユーザー tecchaxntecchaxn
提出日時 2018-03-02 23:06:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 555 bytes
コンパイル時間 2,056 ms
コンパイル使用メモリ 143,628 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-04 06:41:35
合計ジャッジ時間 2,197 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 18 ms
4,380 KB
testcase_05 AC 18 ms
4,376 KB
testcase_06 AC 18 ms
4,380 KB
testcase_07 AC 19 ms
4,376 KB
testcase_08 AC 19 ms
4,376 KB
testcase_09 AC 21 ms
4,380 KB
testcase_10 AC 21 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:19:13: warning: iteration 9996 invokes undefined behavior [-Waggressive-loop-optimizations]
         t[i]=(t[i-1]+t[i-2]+t[i-3]+t[i-4])%mod;
         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:18:18: note: within this loop
     for(int i=4;i<=10000;i++){
                 ~^~~~~~~

ソースコード

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[10000];

signed main()
{   
    t[0]=t[1]=t[2]=0,t[3]=1;
    for(int i=4;i<=10000;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; n--;
        cout<<t[n%4912]<<endl;
    }
 
}
0