結果

問題 No.456 Millions of Submits!
ユーザー pekempeypekempey
提出日時 2016-12-08 04:03:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 738 ms / 4,500 ms
コード長 2,219 bytes
コンパイル時間 1,545 ms
コンパイル使用メモリ 77,924 KB
実行使用メモリ 5,796 KB
最終ジャッジ日時 2023-09-05 12:00:51
合計ジャッジ時間 8,760 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
5,784 KB
testcase_01 AC 7 ms
5,796 KB
testcase_02 AC 7 ms
5,780 KB
testcase_03 AC 7 ms
5,656 KB
testcase_04 AC 7 ms
5,508 KB
testcase_05 AC 8 ms
5,668 KB
testcase_06 AC 7 ms
5,644 KB
testcase_07 AC 8 ms
5,636 KB
testcase_08 AC 8 ms
5,704 KB
testcase_09 AC 15 ms
5,664 KB
testcase_10 AC 15 ms
5,780 KB
testcase_11 AC 80 ms
5,628 KB
testcase_12 AC 738 ms
5,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#pragma GCC optimize ("fast-math")
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cassert>
using namespace std;

#define getchar getchar_unlocked

bool dot;

int in() {
    int n, c;
    while ((c = getchar()) < '0') {
        assert(c != EOF);
    }
    n = c - '0';
    while ((c = getchar()) >= '0') {
        n = n * 10 + c - '0';
    }
    if (c == '.') {
        dot = true;
    }
    return n;
}

const int H = 17;
const int N = 1 << H;
double lg[N];
double lgt[N];

void dfs(int k, double l, double r) {
    if (k < N) {
        lg[k] = log((l + r) / 2);
        dfs(k * 2 + 0, l, (l + r) / 2);
        dfs(k * 2 + 1, (l + r) / 2, r);
    }
}

int main() {
    const double L = 0;
    const double R = log(10);
    const double LL = -1e100;
    const double RR = log(R);

    dfs(1, L, R);

    for (int i = 1; i <= 100000; i++) {
        lgt[i] = log(0.0001 * i);
    }

    int m = in();

    while (m--) {
        int a = in();
        int b = in();
        int c = in();
        int d = dot ? in() : 0;
        double t = c + 1e-4 * d;
        if (b == 0) {
            printf("%.12f\n", pow(t, 1.0 / a));
            continue;
        }
        if (a == 0) {
            printf("%.12f\n", exp(pow(t, 1.0 / b)));
            continue;
        }
        double ok = R;
        double ng = L;
        double logT = lgt[c * 10000 + d];
        double logL = LL;
        double logR = RR;
        int k = 1;
        for (int ii = 0; ii < H; ii++) {
            double mid = (ok + ng) / 2;
            if (a * mid + b * lg[k] >= logT) {
                logR = lg[k];
                k = k * 2 + 0;
                ok = mid;
            } else {
                logL = lg[k];
                k = k * 2 + 1;
                ng = mid;
            }
        }
        for (int ii = H; (ok - ng) > 0.9e-9; ii++) {
            double mid = (ok + ng) / 2;
            double logM = (logL + logR) / 2;
            if (a * mid + b * logM >= logT) {
                ok = mid;
                logR = logM;
            } else {
                ng = mid;
                logL = logM;
            }
        }
        printf("%.12f\n", exp(ok));
    }
}
0