結果

問題 No.657 テトラナッチ数列 Easy
コンテスト
ユーザー mukadenodaiou
提出日時 2018-03-21 18:44:30
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,031 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,016 ms
コンパイル使用メモリ 126,432 KB
実行使用メモリ 11,464 KB
最終ジャッジ日時 2026-03-08 19:04:38
合計ジャッジ時間 1,898 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const ll INF = std::numeric_limits<long long>::max();
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define sz size
const ll mod = 17;
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll q, v[1000001],n;
int main() {
	cin >> q;
	v[0] = 0; v[1] = 0; v[2] = 0; v[3] = 1;
	for (ll i = 4; i < 1000001; ++i) { v[i] = v[i - 1] + v[i - 2] + v[i - 3] + v[i - 4]; v[i] %= mod; }
	rep(i, q) {
		cin >> n;
		cout << v[n - 1] << endl;
	}
	return 0;
}
0