結果

問題 No.456 Millions of Submits!
ユーザー cielciel
提出日時 2016-12-09 12:56:17
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,408 ms / 4,500 ms
コード長 1,528 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 47,492 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-05 21:35:12
合計ジャッジ時間 10,095 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 26 ms
4,376 KB
testcase_10 AC 26 ms
4,380 KB
testcase_11 AC 245 ms
4,504 KB
testcase_12 AC 2,408 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#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);
	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=a/b*pow(t,1/b);
			printf("%.9f\n",pow(binarysearch(min(M_E,t),max(M_E,t),[&](const double &n)->bool{
				return n*log(n)>=t;
			}),b/a));
		}
	}
}
0