結果
問題 | No.456 Millions of Submits! |
ユーザー |
|
提出日時 | 2016-12-09 11:35:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,512 bytes |
コンパイル時間 | 329 ms |
コンパイル使用メモリ | 40,192 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-23 16:52:36 |
合計ジャッジ時間 | 2,102 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 RE * 6 |
ソースコード
#include <cstdio>#include <cmath>using namespace std;// cpp_binarysearch (C) @cielavenir under Boost Software License.// returns the smallest value satisfying the predicate.// type F should be something like std::function<bool(T)>.template<typename T,typename F>T binarysearch(T lo,T hi,const T eps,const F &predicate){T r=hi+eps;for(;lo<hi+eps;){T mi=eps!=1||(lo<0)==(hi<0) ? lo+(hi-lo)/2 : (lo<-hi) ? -((-lo-hi-1)/2+1) : (lo+hi)/2;if(predicate(mi)){r=mi;hi=mi-eps;}else{lo=mi+eps;}}return r;}template<typename T,typename F>T binarysearch(T lo,T hi,const F &predicate){return binarysearch(lo,hi,(T)1,predicate);}template<typename F>double binarysearch(double _lo,double _hi,const F &predicate){long long lo;if(_lo<0)_lo=-_lo,lo=-*(long long*)(&_lo);else lo=*(long long*)(&_lo);long long hi;if(_hi<0)_hi=-_hi,hi=-*(long long*)(&_hi);else hi=*(long long*)(&_hi);long long _r=binarysearch(lo,hi,1LL,[&](long long _mi){double mi;if(_mi<0)_mi=-_mi,mi=-*(double*)(&_mi);else mi=*(double*)(&_mi);return predicate(mi);});double r;if(_r<0)_r=-_r,r=-*(double*)(&_r);else r=*(double*)(&_r);return r;}int main(){int m;double a,b,t;scanf("%d",&m);if(m>100)return 1;for(;m--;){scanf("%lf%lf%lf",&a,&b,&t);if(!a)printf("%.9f\n",exp(pow(t,1/b)));else if(!b)printf("%.9f\n",pow(t,1/a));else{t=pow(t,1/a);printf("%.9f\n",binarysearch(1.0,100.0,[&](const double &n)->bool{return n*pow(log(n),b/a)>=t;}));}}}