結果

問題 No.657 テトラナッチ数列 Easy
ユーザー hitoyozakehitoyozake
提出日時 2018-04-14 16:10:48
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 764 bytes
コンパイル時間 1,464 ms
コンパイル使用メモリ 70,812 KB
実行使用メモリ 66,164 KB
最終ジャッジ日時 2023-09-09 05:12:25
合計ジャッジ時間 9,605 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <map>
#include <vector>

int tetra(std::map<int, long long int> & map, long long int const n)
{
    if(n<=3)
        return 0;
    if(n==4)
        return 1;

    if(map.find(n) == map.end())
    {
        map[n] = tetra(map, n-1) + tetra(map, n-2) + tetra(map, n-3) + tetra(map, n-4);
        
    }

    return map[n];

}


int main()
{
    int num = 0;
    std::map<int, long long int> map;
    std::cin >> num;
    std::vector<int> v;
    for( int i = 0; i < num; ++i)
    {
        int x = 0;
        std::cin >> x;
        for(int j = 0; j < x; ++j)
        {
            tetra(map, j);
        }
        v.push_back(tetra(map, x));
    }

    for( auto i: v)
    {
        std::cout << i%17 << std::endl;
    }

    return 0;
}
0