結果

問題 No.456 Millions of Submits!
ユーザー imulanimulan
提出日時 2016-12-08 04:08:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,450 ms / 4,500 ms
コード長 1,182 bytes
コンパイル時間 1,499 ms
コンパイル使用メモリ 165,288 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 12:02:40
合計ジャッジ時間 11,770 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 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,376 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 27 ms
4,376 KB
testcase_10 AC 27 ms
4,380 KB
testcase_11 AC 246 ms
4,376 KB
testcase_12 AC 2,450 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

inline double F(double x, int a, int b, double t)
{
    double pa=pow(x,a-1), pb=pow(log(x),b-1);

    double C = pa*x * pb*log(x) - t;
    double D = pa * pb * (a*log(x)+b);
    return C/D;
}

const double eps=1e-9;

int main()
{
    int m;
    scanf(" %d", &m);
    while(m--)
    {
        int a,b;
        double t;
        scanf(" %d %d %lf", &a, &b, &t);

        double ans;
        if(a==0) ans = pow(exp(1), pow(t,1.0/b));
        else if(b==0) ans = pow(t,1.0/a);
        else
        {
            double x=10;
            if(a>=2 && b>=2) x=2.94;
            double oldx=0;

            // int ct=0;
            while(fabs(x-oldx)>eps)
            {
                // ++ct;
                oldx = x;
                x = x - F(x,a,b,t);
            }

            // printf("ct=%d\n", ct);
            ans = x;
        }

        printf("%.10f\n", ans);
    }
    return 0;
}
0