結果
問題 | No.456 Millions of Submits! |
ユーザー | はむこ |
提出日時 | 2016-11-29 16:21:25 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,592 bytes |
コンパイル時間 | 1,569 ms |
コンパイル使用メモリ | 160,364 KB |
実行使用メモリ | 10,528 KB |
最終ジャッジ日時 | 2024-06-23 01:11:04 |
合計ジャッジ時間 | 15,451 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:111:22: warning: format ‘%lf’ expects argument of type ‘double’, but argument 2 has type ‘Double’ {aka ‘long double’} [-Wformat=] 111 | printf("%.12lf\n", w_ret); | ~~~~~^ ~~~~~ | | | | | Double {aka long double} | double | %.12Lf main.cpp:97:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 97 | int m; scanf("%d", &m); | ~~~~~^~~~~~~~~~ main.cpp:100:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 100 | int a, b; scanf("%d%d", &a, &b); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:101:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 101 | Double t; scanf("%Lf", &t); | ~~~~~^~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(long long i = 0; i < (long long)(n); i++) #define pb push_back #define all(x) (x).begin(), (x).end() template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); } template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) { o << "(" << v.first << ", " << v.second << ")"; return o; } template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { if (!v.empty()) { o << '['; copy(v.begin(), v.end(), ostream_iterator<T>(o, ", ")); o << "\b\b]"; } return o; } using ll = long long; using vll = vector<ll>; using vi = vector<int>; typedef pair<ll, ll> P; static const double EPS = 1e-14; static const long long INF = 1e18; #define MAX_N 100005 typedef long double Double; /* ランベルトのW関数 * http://keithbriggs.info/software/LambertW.c * */ const double eps=4.0e-16, em1=0.3678794411714423215955237701614608; double LambertW(const double z) { int i; double p,e,t,w; #ifdef DEBUG fprintf(stderr,"LambertW: z=%g\n",z); if (z<-em1 || ::isinf(z) || ::isnan(z)) { fprintf(stderr,"LambertW: bad argument %g, exiting.\n",z); exit(1); } #endif if (0.0==z) return 0.0; if (z<-em1+1e-4) { // series near -em1 in sqrt(q) double q=z+em1,r=sqrt(q),q2=q*q,q3=q2*q; return -1.0 +2.331643981597124203363536062168*r -1.812187885639363490240191647568*q +1.936631114492359755363277457668*r*q -2.353551201881614516821543561516*q2 +3.066858901050631912893148922704*r*q2 -4.175335600258177138854984177460*q3 +5.858023729874774148815053846119*r*q3 -8.401032217523977370984161688514*q3*q; // error approx 1e-16 } /* initial approx for iteration... */ if (z<1.0) { /* series near 0 */ p=sqrt(2.0*(2.7182818284590452353602874713526625*z+1.0)); w=-1.0+p*(1.0+p*(-0.333333333333333333333+p*0.152777777777777777777777)); } else w=log(z); /* asymptotic */ if (z>3.0) w-=log(w); /* useful? */ for (i=0; i<10; i++) { /* Halley iteration */ e=exp(w); t=w*e-z; p=w+1.0; t/=e*p-0.5*(p+1.0)*t/p; w-=t; if (fabs(t)<eps*(1.0+fabs(w))) return w; /* rel-abs error */ } /* should never get here */ fprintf(stderr,"LambertW: No convergence at z=%g, exiting.\n",z); exit(1); } Double binary(Double a, Double b, Double t) { if (!a) { return exp(pow(t, 1.0l / b)); } if (!b) { return pow(t, 1.0l / a); } Double rl = 1e-12; Double rr = 11; rep(i, 100) { Double m = (rl + rr) / 2; (pow(m, a) * pow(log(m), b) - t > 0) ? rr = m : rl = m; } return rl; } Double w(Double a, Double b, Double t) { if (!a) { return expl(powl(t, 1.0l / b)); } if (!b) { return powl(t, 1.0l / a); } return expl(1.0l * b / a * LambertW(1.0l * a / b * powl(t, 1.0l / b))); } int main(void) { int m; scanf("%d", &m); Double maxerr = -INF; rep(i, m) { int a, b; scanf("%d%d", &a, &b); Double t; scanf("%Lf", &t); Double binary_ret = binary(a, b, t); Double w_ret = w(a, b, t); /* if (abs(binary_ret - w_ret) > 1e-9) { cout << "!!!!!!!!!!!!!!!!" << endl; exit(1); } */ printf("%.12lf\n", w_ret); } return 0; }