結果

問題 No.658 テトラナッチ数列 Hard
ユーザー ohreitetsuohreitetsu
提出日時 2018-03-21 14:00:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 898 bytes
コンパイル時間 763 ms
コンパイル使用メモリ 79,072 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-07 00:53:59
合計ジャッジ時間 4,255 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,484 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
struct X{
	int index;
	LL n;
	int val;
};
bool CompN(X &l, X &r){
	return l.n<r.n;
}
bool CompI(X &l, X &r){
	return l.index<r.index;
}
int main(int argc, char* argv[])
{
	int Q;
	cin>>Q;
	int i;
	vector<X> N(Q);
	for (i=0;i<Q;i++){
		cin>>N[i].n;
		N[i].index=i;
		N[i].val=0;
	}
	sort(N.begin(),N.end(),CompN);
	vector<int> T1;
	T1.push_back(0);
	T1.push_back(0);
	T1.push_back(0);
	T1.push_back(1);
	LL t=4;
	for (i=0;i<Q;i++){
		switch(N[i].n){
		case 1:
		case 2:
		case 3:
			break;
		case 4:
			N[i].val=1;
			break;
		default:
			int Sum;
			while (t<N[i].n){
				Sum=(T1[0]+T1[1]+T1[2]+T1[3])%17;
				T1.push_back(Sum);
				T1.erase(T1.begin());
				t++;
			}
			N[i].val=T1[3];
			break;
		}
	}
	sort(N.begin(),N.end(),CompI);
	for (i=0;i<Q;i++){
		cout<<N[i].val<<endl;
	}
	return 0;
}
0