結果

問題 No.657 テトラナッチ数列 Easy
ユーザー shikakushikaku
提出日時 2018-04-25 08:19:00
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 964 bytes
コンパイル時間 572 ms
コンパイル使用メモリ 61,976 KB
実行使用メモリ 11,528 KB
最終ジャッジ日時 2023-09-10 05:22:13
合計ジャッジ時間 4,724 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
                                                                                                
  
int tori( int x ){

    vector<int> t(1000000);


    if( x == 1 || x == 2 || x == 3 ) return 0;

    else if( x == 4 ) return 1;

    else if( x > 4 ){

             int i;

             t.at(1) = 0;

             t.at(2) = 0;

             t.at(3) = 0;

             t.at(4) = 1;


             for( i = 5 ; i <= x ; i = i + 1 ){

                  t.at(i) = ( t.at(i - 1) + t.at(i - 2) + t.at(i - 3) + t.at(i - 4) ) % 17;

                  }

             }

    return t.at(x);

    }


int main(){


    long long q, i;

    
    cin >> q;

    vector<long long> n(q);


    for( i = 0 ; i < q ; i = i + 1 ){

        cin >> n.at(i);

        }
                                            
    for( i = 0 ; i < q ; i = i + 1 ){

        cout << tori( n.at(i) ) << endl;

        }


    return 0;

}
0