結果

問題 No.691 E869120 and Constructing Array 5
ユーザー 👑 kmjpkmjp
提出日時 2018-05-19 00:55:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 489 ms / 1,000 ms
コード長 1,579 bytes
コンパイル時間 1,716 ms
コンパイル使用メモリ 158,640 KB
実行使用メモリ 19,480 KB
最終ジャッジ日時 2023-09-11 00:12:06
合計ジャッジ時間 14,905 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 489 ms
19,480 KB
testcase_01 AC 434 ms
4,376 KB
testcase_02 AC 410 ms
4,380 KB
testcase_03 AC 392 ms
4,376 KB
testcase_04 AC 414 ms
4,380 KB
testcase_05 AC 398 ms
4,380 KB
testcase_06 AC 400 ms
4,380 KB
testcase_07 AC 404 ms
4,380 KB
testcase_08 AC 395 ms
4,376 KB
testcase_09 AC 410 ms
4,380 KB
testcase_10 AC 409 ms
4,380 KB
testcase_11 AC 423 ms
4,376 KB
testcase_12 AC 403 ms
4,376 KB
testcase_13 AC 397 ms
4,376 KB
testcase_14 AC 409 ms
4,376 KB
testcase_15 AC 411 ms
4,380 KB
testcase_16 AC 399 ms
4,380 KB
testcase_17 AC 411 ms
4,380 KB
testcase_18 AC 402 ms
4,376 KB
testcase_19 AC 404 ms
4,380 KB
testcase_20 AC 411 ms
4,380 KB
testcase_21 AC 404 ms
4,376 KB
testcase_22 AC 408 ms
4,376 KB
testcase_23 AC 416 ms
4,376 KB
testcase_24 AC 405 ms
4,384 KB
testcase_25 AC 417 ms
4,380 KB
testcase_26 AC 399 ms
4,380 KB
testcase_27 AC 3 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int Q;
long double A;

vector<int> hoge(long double A) {
	int T2=A/8;
	vector<pair<long double,vector<int>>> C;
	int i;
	while(C.size()<100) {
		int x=rand()%(T2*T2);
		long double B=A/8-sqrt(x);
		int c[2]={(int)(B*B),(int)(B*B)+1};
		FOR(i,2) if(abs(A/8-(sqrt(x)+sqrt(c[i])))<5e-5) C.push_back({sqrt(x)+sqrt(c[i]),{x,c[i]}});
	}
	long double T=A/4, eps=5e-7;
	FOR(i,3) {
		vector<pair<long double,vector<int>>> C2;
		FORR(a,C) FORR(b,C) if(abs(T-(a.first+b.first))<eps) {
			vector<int> V=a.second;
			FORR(v,b.second) V.push_back(v);
			C2.push_back({a.first+b.first,V});
		}
		C=C2;
		T*=2;
		eps *= 1e-2;
	}
	if(C.size()) return C[0].second;
	return vector<int>();
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	srand(time(NULL));
	cin>>Q;
	while(Q--) {
		cin>>A;
		vector<int> V;
		while(1) {
			V=hoge(A);
			if(V.size()) break;
		}
		cout<<V.size();
		FORR(v,V) cout<<" "<<v;
		cout<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0