結果

問題 No.657 テトラナッチ数列 Easy
ユーザー dong_fengdong_feng
提出日時 2018-06-07 23:57:41
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 752 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 28,340 KB
実行使用メモリ 11,484 KB
最終ジャッジ日時 2023-09-12 23:12:02
合計ジャッジ時間 4,881 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 9 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 11 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

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