結果

問題 No.657 テトラナッチ数列 Easy
ユーザー yuruhiyayuruhiya
提出日時 2019-02-06 18:06:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 1,614 bytes
コンパイル時間 846 ms
コンパイル使用メモリ 96,216 KB
実行使用メモリ 11,076 KB
最終ジャッジ日時 2023-09-03 18:37:28
合計ジャッジ時間 2,584 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,812 KB
testcase_01 AC 4 ms
6,708 KB
testcase_02 AC 4 ms
6,696 KB
testcase_03 AC 4 ms
6,760 KB
testcase_04 AC 11 ms
10,656 KB
testcase_05 AC 18 ms
6,736 KB
testcase_06 AC 4 ms
6,700 KB
testcase_07 AC 4 ms
6,932 KB
testcase_08 AC 11 ms
10,824 KB
testcase_09 AC 19 ms
6,884 KB
testcase_10 AC 20 ms
6,772 KB
testcase_11 AC 20 ms
6,704 KB
testcase_12 AC 21 ms
7,360 KB
testcase_13 AC 28 ms
10,920 KB
testcase_14 AC 29 ms
10,820 KB
testcase_15 AC 28 ms
11,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <ctime>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

VI t(1000009, -1);

int T(int n) {
	switch (n) {
	case 0:
	case 1:
	case 2:
	case 3:
		return 0;
		break;
	case 4:
		return 1;
		break;
	default:
		if (t[n] != -1)return t[n];
		else {
			int t1 = (T(n - 1) + T(n - 2) + T(n - 3) + T(n - 4)) % 17;;
			return t[n] = t1;
		}
		break;
	}
}

int main() {
	int q; cin >> q;
	VI n(q); rep(i, q)cin >> n[i];

	int max = *max_element(all(n));
	VI t(max + 10);
	rep(i, max+1) {
		switch (i) {
		case 0:
		case 1:
		case 2:
		case 3:
			t[i] = 0;
			break;
		case 4:
			t[i] = 1;
			break;
		default:
			t[i] = (t[i - 1] + t[i - 2] + t[i - 3] + t[i - 4]) % 17;
			break;
		}
	}
	rep(i, q) {
		cout << t[n[i]] << endl;
	}
}
0