結果

問題 No.657 テトラナッチ数列 Easy
ユーザー dong_fengdong_feng
提出日時 2018-06-07 23:59:47
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 778 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 28,436 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-12 23:12:07
合計ジャッジ時間 4,853 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,760 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 9 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 10 ms
4,376 KB
testcase_09 AC 30 ms
4,376 KB
testcase_10 AC 436 ms
4,380 KB
testcase_11 AC 434 ms
4,376 KB
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;
        
        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]);
        }
        sum=history[3];
        if(times<4){
            sum=history[times-1];
        }
        
        printf("%d\n",sum);
    }
    
    return 0;
}
0