結果
問題 |
No.691 E869120 and Constructing Array 5
|
ユーザー |
![]() |
提出日時 | 2025-09-21 22:59:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 240 ms / 1,000 ms |
コード長 | 906 bytes |
コンパイル時間 | 925 ms |
コンパイル使用メモリ | 94,700 KB |
実行使用メモリ | 19,460 KB |
最終ジャッジ日時 | 2025-09-21 22:59:19 |
合計ジャッジ時間 | 8,939 ms |
ジャッジサーバーID (参考情報) |
judge4 / 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(); } }