結果

問題 No.657 テトラナッチ数列 Easy
ユーザー focusfocus
提出日時 2018-03-05 15:49:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 482 bytes
コンパイル時間 605 ms
コンパイル使用メモリ 72,960 KB
実行使用メモリ 39,396 KB
最終ジャッジ日時 2023-09-28 22:04:08
合計ジャッジ時間 1,867 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 43 ms
39,176 KB
testcase_05 AC 16 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 43 ms
39,396 KB
testcase_09 AC 17 ms
4,376 KB
testcase_10 AC 17 ms
4,376 KB
testcase_11 AC 18 ms
4,376 KB
testcase_12 AC 23 ms
6,916 KB
testcase_13 AC 55 ms
31,248 KB
testcase_14 AC 59 ms
37,680 KB
testcase_15 AC 49 ms
21,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<bitset>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
#define ll long long
ll memo[1000001]={};
ll tetora(ll n){
    if(n<4)    return 0;
    else if(n==4)   return 1;
    if(memo[n]==0) memo[n] = (tetora(n-1)+tetora(n-2)+tetora(n-3)+tetora(n-4))%17;
    return memo[n];
}

int main(){
    ll Q,num;
    cin >> Q;
    while(Q--){
        cin >> num;
        cout << tetora(num) << endl;
    }
    return 0;
}
0