結果

問題 No.691 E869120 and Constructing Array 5
ユーザー tailstails
提出日時 2018-05-21 11:56:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 258 ms / 1,000 ms
コード長 906 bytes
コンパイル時間 606 ms
コンパイル使用メモリ 68,664 KB
実行使用メモリ 19,304 KB
最終ジャッジ日時 2023-09-11 00:18:06
合計ジャッジ時間 9,349 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 225 ms
19,168 KB
testcase_01 AC 233 ms
19,084 KB
testcase_02 AC 246 ms
19,092 KB
testcase_03 AC 243 ms
19,248 KB
testcase_04 AC 244 ms
19,232 KB
testcase_05 AC 244 ms
19,252 KB
testcase_06 AC 245 ms
19,136 KB
testcase_07 AC 242 ms
19,160 KB
testcase_08 AC 244 ms
19,164 KB
testcase_09 AC 243 ms
19,104 KB
testcase_10 AC 244 ms
19,096 KB
testcase_11 AC 245 ms
19,180 KB
testcase_12 AC 245 ms
19,104 KB
testcase_13 AC 242 ms
19,104 KB
testcase_14 AC 248 ms
19,092 KB
testcase_15 AC 243 ms
19,148 KB
testcase_16 AC 252 ms
19,304 KB
testcase_17 AC 238 ms
19,112 KB
testcase_18 AC 253 ms
19,148 KB
testcase_19 AC 241 ms
19,084 KB
testcase_20 AC 251 ms
19,252 KB
testcase_21 AC 238 ms
19,096 KB
testcase_22 AC 251 ms
19,096 KB
testcase_23 AC 242 ms
19,088 KB
testcase_24 AC 250 ms
19,176 KB
testcase_25 AC 246 ms
19,224 KB
testcase_26 AC 258 ms
19,180 KB
testcase_27 AC 128 ms
19,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

struct S{
	int e1,e2;
	double d;
};
S s[1000000];

bool f(double p,double d,int i,int j){
	while(i<j){
		double e=d-(s[i].d+s[j].d);
		if(fabs(e)<9e-11){
			double y=p-(sqrt(s[i].e1)+sqrt(s[i].e2)+sqrt(s[j].e1)+sqrt(s[j].e2));
			cout << "5 "
			     << s[i].e1 << " "
			     << s[i].e2 << " "
			     << s[j].e1 << " "
			     << s[j].e2 << " "
			     << int(y*y+0.5)
			     << endl;
			return true;
		}
		e<0?--j:++i;
	}
	return false;
}

void g(){
	double p,d,x;
	cin>>p;
	d=modf(p,&x);
	f(p,d,0,999999*d)||f(p,d+1,999999*d,999999);
}

int main(){
	int i=0;
	for(int a=1000;a<2000;++a){
		for(int b=0;b<1000;++b){
			double x=sqrt(a)+sqrt(b);
			double d=modf(x,&x);
			s[i].e1=a;
			s[i].e2=b;
			s[i].d=d;
			++i;
		}
	}
	sort(s,s+i,[](S const&a,S const&b){return a.d<b.d;});
	int q;
	cin>>q;
	for(;q--;){
		g();
	}
}
0