結果

問題 No.456 Millions of Submits!
ユーザー parukiparuki
提出日時 2016-12-07 23:55:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
OLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,991 bytes
コンパイル時間 1,758 ms
コンパイル使用メモリ 163,840 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 08:23:56
合計ジャッジ時間 8,076 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

/**
b = 0のとき
n^a = t
a!=0なので
より
n = t^(1/a)

(a,b) = (0,1)
log(n) = t >= 1.0
n > e
log(n) = log(e^t)
n = e^t

(a,b) = (0, b) (b!=0)
x = e^t^(1/b)

(a,b)=(1,1)
x = t/W(t)

(a,b)=(2,1)
x = sqrt(2t/W(2t))

(a,b)=(1,2)
x = e^(2W(sqrt(t)/2))

(a,b)=(2,2)
x = e^(W(sqrt(T))


a!=0 b!=0
e^(b/a*W(a/b * t^(1/b))
**/


double lambertWFunction(double z) {
    double w = 5;
    for(int i = 0; i < 15; ++i) {
        double ew = exp(w);
        double den = ew + w*ew;
        if(den < 1e-13)break;
        double x = (w*ew - z) / (ew + w*ew);
        w = w - x;
    }
    return w;
}

double lambertWFunction2(double z) {
    double w = 5;
    for(int i = 0; i < 12; ++i) {
        double ew = exp(w);
        double x = (w*ew - z) / (ew*(w + 1) - (w + 2)*(w*ew - z) / (2 * w + 2));
        w = w - x;
    }
    return w;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    while(n--) {
        int a, b;
        double t;
        cin >> a >> b >> t;
        double ans = 0;
        if(a == 0) {
            // e^t^(1/b)
            double p = pow(t, 1.0 / b);
            ans = exp(p);
        } else if(b == 0) {
            // n = t^(1/a)
            ans = pow(t, 1.0 / a);
        } else {
            // e^(b/a*W(a/b * t^(1/b))
            double w = lambertWFunction2((double)a / b*pow(t, 1.0 / b));
            ans = exp((double)b / a*w);
        }
        cout << setprecision(20) << ans << endl;
    }
}
0