結果

問題 No.456 Millions of Submits!
ユーザー kyuridenamida
提出日時 2016-12-08 04:01:35
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2,104 ms / 4,500 ms
コード長 761 bytes
コンパイル時間 1,358 ms
コンパイル使用メモリ 158,472 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-23 07:31:30
合計ジャッジ時間 6,130 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:40:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   40 |                 scanf("%Lf%Lf%Lf",&a,&b,&t);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~

ソースコード

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 f(double x){
	return a * x + b * log(x) - log(t);
}
double fd(double x){
	return a + b / x;
}


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

	}
	return exp(x);
}





int main(){
	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