結果
問題 | No.456 Millions of Submits! |
ユーザー |
![]() |
提出日時 | 2016-12-08 03:59:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2,462 ms / 4,500 ms |
コード長 | 1,567 bytes |
コンパイル時間 | 1,268 ms |
コンパイル使用メモリ | 158,932 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 07:27:28 |
合計ジャッジ時間 | 6,284 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:86:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 86 | scanf("%Lf%Lf%Lf",&a,&b,&t); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
// もちろん落ちるけど#include <bits/stdc++.h>using namespace std;typedef double Double;#define double long doubleconst 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;}}