結果

問題 No.456 Millions of Submits!
ユーザー kyuridenamidakyuridenamida
提出日時 2016-12-08 03:59:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,875 ms / 4,500 ms
コード長 1,567 bytes
コンパイル時間 1,989 ms
コンパイル使用メモリ 144,524 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 11:50:19
合計ジャッジ時間 7,321 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

// もちろん落ちるけど
#include <bits/stdc++.h>
using namespace std;
typedef double Double;
#define double long double
const double EPS = 1e-12;

double a,b,t;


double mylog(double x){
	return log(x);
	double i=1;   // (i.e. not 3)
	double logx = 0 ;
	double ty = (x-1)/(x+1),tty;
	do
	{
	    logx = logx + ty / i;
	    tty = ty ;
	    ty = (ty * ((x-1)/(x+1)) * ((x-1)/(x+1)));
	    i = i + 2 ;
	} while(tty - ty > EPS );
	return 2 * logx;
}

const double e = 2.718281828459045235360287471352662497757247093699;
double myexp(double x){
	return exp(x);
	int intp = (int)x;
	double realp = x - intp;

	double ans1 = 1;
	for(int i = 0 ; i < intp ; i++){
		ans1 *= e;
	}
	

	double ans2 = 0;
	double den = 1;
	double num = 1;
	double f = 1;
	for(int i = 1 ; i <= 20 ; i++){
		ans2 += num / den;
		den *= i;
		num *= realp;
	}
	return ans1 * ans2;
}


double f(double m){
	return a * m + b * mylog(m) - mylog(t);
}
double fd(double x){
	return a + b / x;
}


double initv = 0.0001;
double solve(){
	if( a == 0 ){

	}
	if( b == 0 ){
		return pow(t,(double)1./a);
	}
	double x = initv;
	for(int i = 0 ; i < 25 ; i++){ 
		x = x - f(x) / fd(x);

	}
	return myexp(x);
}





int main(){
	//cout << mylog(10) << " " << mylog(e*e) << endl;
	//printf("%.16lf\n",(Double)myexp(1.9));
	int n;
	cin >> n;
	for(int i = 0 ; i < n ; i++){
		
		scanf("%Lf%Lf%Lf",&a,&b,&t);
		Double ans;
		while(1){
			ans = (Double)solve();
			if( isnan((double)ans)){
				initv = (rand() % 10000+1)/1000.;
			}else break;
		}

		printf("%.12lf\n",ans);
		//cout << solve(a,b,t) << endl;
	}
}
0