結果

問題 No.657 テトラナッチ数列 Easy
ユーザー dong_feng
提出日時 2018-06-07 23:57:41
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 752 bytes
コンパイル時間 126 ms
コンパイル使用メモリ 29,568 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-06-30 10:36:20
合計ジャッジ時間 4,899 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 2 WA * 7 TLE * 1 -- * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int modular17(int input){
    while(input>=17){
        input-=17;
    }
    return input;
}

int main(void){
    int query;
    int i,j,k;
    int times;
    int sum;
    int history[4];
    
    scanf("%d",&query);
    for(i=0;i<query;i++){
        scanf("%d",&times);
        history[0]=0;
        history[1]=0;
        history[2]=0;
        history[3]=1;
        
        if(times<4){
            sum=history[times-1];
        }
        for(j=4;j<times;j++){
            sum=0;
            for(k=0;k<3;k++){
                sum+=modular17(history[k]);
                history[k]=history[k+1];
            }
            history[3]=modular17(sum+history[3]);
        }
        printf("%d\n",history[3]);
    }
    
    return 0;
}
0