結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,760 KB
testcase_01 AC 12 ms
6,704 KB
testcase_02 AC 12 ms
6,928 KB
testcase_03 AC 12 ms
6,932 KB
testcase_04 AC 12 ms
6,544 KB
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 lglg[N];
double lgt[N];

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

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

    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 loglogL = LLL;
        double loglogR = RRR;
        double logT = lgt[c * 10000 + d];
        int k = 1;
        for (int ii = 0; ii < H; ii++) {
            double mid = (l + r) / 2;
            if (a * lg[k] + b * lglg[k] >= logT) {
                logR = lg[k];
                loglogR = lglg[k];
                k = k * 2 + 0;
                r = mid;
            } else {
                logL = lg[k];
                loglogL = lglg[k];
                k = k * 2 + 1;
                l = mid;
            }
        }
        long double p = ((long double)logR - logL) / (long double)(r - l);
        long double q = ((long double)loglogR - loglogL) / (long double)(r - l);
        double ans = (logT + (p * a + q * b) * l - (logL * a + loglogL * b)) / (p * a + q * b);
        printf("%.9f\n", ans);
    }
}
0