結果

問題 No.657 テトラナッチ数列 Easy
コンテスト
ユーザー CreativeGP1
提出日時 2018-03-04 23:37:19
言語 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  
実行時間 -
コード長 840 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 779 ms
コンパイル使用メモリ 95,616 KB
実行使用メモリ 208,640 KB
最終ジャッジ日時 2026-04-01 14:27:41
合計ジャッジ時間 8,224 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 5 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* ========================================================================
   $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