結果

問題 No.657 テトラナッチ数列 Easy
ユーザー CreativeGP1CreativeGP1
提出日時 2018-03-04 23:37:19
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 840 bytes
コンパイル時間 529 ms
コンパイル使用メモリ 73,084 KB
実行使用メモリ 136,508 KB
最終ジャッジ日時 2023-09-24 22:59:35
合計ジャッジ時間 10,854 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/* ========================================================================
   $File: $
   $Date: $
   $Revision: $
   $Creator: Creative GP $
   $Notice: (C) Copyright 2017 by Creative GP, Inc. All Rights Reserved. $
   ======================================================================== */

#define CPP

#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <map>
#include <list>

#define ll long long

using namespace std;

map<ll,ll> memo = {
    {1, 0},
    {2, 0},
    {3, 0},
    {4, 1}
};

int tetra(ll n) {
    if (memo.find(n) != memo.end()) return memo[n];
    memo[n] = tetra(n-1)+tetra(n-2)+tetra(n-3)+tetra(n-4);
    return memo[n];
}

int main()
{
    ll Q;
    cin >> Q;
    for (ll i = 0; i < Q; i++) {
      	int t;
        cin >> t;
        cout << tetra(t) % 17 << endl;
    }
}





0