結果

問題 No.657 テトラナッチ数列 Easy
ユーザー hitoyozake
提出日時 2018-04-14 16:15:46
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 769 bytes
コンパイル時間 693 ms
コンパイル使用メモリ 72,136 KB
実行使用メモリ 65,792 KB
最終ジャッジ日時 2024-06-26 22:18:00
合計ジャッジ時間 9,714 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other AC * 6 TLE * 2 -- * 5
権限があれば一括ダウンロードができます

ソースコード

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))%17;
        
    }

    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