結果

問題 No.657 テトラナッチ数列 Easy
コンテスト
ユーザー hitoyozake
提出日時 2018-04-14 16:10:48
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 764 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 736 ms
コンパイル使用メモリ 93,432 KB
実行使用メモリ 69,504 KB
最終ジャッジ日時 2026-03-13 19:37:46
合計ジャッジ時間 23,306 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 5 WA * 2 TLE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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