結果

問題 No.657 テトラナッチ数列 Easy
ユーザー snow4726snow4726
提出日時 2018-03-10 14:13:39
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 1,011 bytes
コンパイル時間 1,444 ms
コンパイル使用メモリ 29,440 KB
実行使用メモリ 9,728 KB
最終ジャッジ日時 2024-04-21 10:35:21
合計ジャッジ時間 1,086 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
#include<inttypes.h>

int main(){

    long long int* data;
    long long int* line;
    long long int i,n;
    long long int max = -1;

    scanf("%"SCNd64"",&n);
    data = (long long int*)calloc(n,sizeof(long long int));
    for(i=0; i<n; i++){
            scanf("%"SCNd64"",data+i);
            if( max < data[i] ) max = data[i];
    }
    line = (long long int*)calloc(max,sizeof(long long int));

    for(i=1; i<=max; i++){
        switch(i){
            case 1:
                line[i-1] = 0;
                break;
            case 2:
                line[i-1] = 0;
                break;
            case 3:
                line[i-1] = 0;
                break;
            case 4:
                line[i-1] = 1;
                break;
            default:
                line[i-1] = (line[i-2] + line[i-3] + line[i-4] + line[i-5])%17;
                break;
        }
    }

    for(i=0; i<n; i++){
        printf("%lld\n",line[data[i]-1]);
    }

    return 0;
}
0