結果

問題 No.456 Millions of Submits!
ユーザー pekempeypekempey
提出日時 2016-12-08 04:26:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,009 bytes
コンパイル時間 923 ms
コンパイル使用メモリ 76,744 KB
実行使用メモリ 5,904 KB
最終ジャッジ日時 2023-09-05 12:03:14
合計ジャッジ時間 3,916 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

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("%.9f\n", pow(t, 1.0 / a));
            continue;
        }
        if (a == 0) {
            printf("%.9f\n", exp(pow(t, 1.0 / b)));
            continue;
        }
        double l = L;
        double r = R;
        double logL = LL;
        double logR = RR;
        double logT = lgt[c * 10000 + d];
        int k = 1;
        for (int ii = 0; ii < H; ii++) {
            double mid = (l + r) / 2;
            if (a * mid + b * lg[k] >= logT) {
                logR = lg[k];
                k = k * 2 + 0;
                r = mid;
            } else {
                logL = lg[k];
                k = k * 2 + 1;
                l = mid;
            }
        }
        long double s = (long double)logR - logL / (long double)(r - l);
        long double ans = (t + s * l - logL) / (s + a);
        printf("%.9f\n", (double)exp(ans));
    }
}
0