結果
問題 | No.691 E869120 and Constructing Array 5 |
ユーザー |
![]() |
提出日時 | 2018-05-21 11:56:49 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 227 ms / 1,000 ms |
コード長 | 906 bytes |
コンパイル時間 | 827 ms |
コンパイル使用メモリ | 69,632 KB |
実行使用メモリ | 19,200 KB |
最終ジャッジ日時 | 2024-06-28 14:55:29 |
合計ジャッジ時間 | 8,160 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 27 |
ソースコード
#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(); } }