結果

問題 No.456 Millions of Submits!
ユーザー pekempeypekempey
提出日時 2016-12-08 05:02:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,130 bytes
コンパイル時間 1,619 ms
コンパイル使用メモリ 77,976 KB
実行使用メモリ 5,924 KB
最終ジャッジ日時 2023-09-05 12:10:36
合計ジャッジ時間 3,813 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,740 KB
testcase_01 AC 6 ms
5,776 KB
testcase_02 AC 6 ms
5,780 KB
testcase_03 AC 6 ms
5,744 KB
testcase_04 AC 6 ms
5,720 KB
testcase_05 AC 6 ms
5,628 KB
testcase_06 AC 6 ms
5,924 KB
testcase_07 AC 6 ms
5,764 KB
testcase_08 AC 7 ms
5,888 KB
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, double ll, double rr) {
    if (k < N) {
        if (rr - ll > 1e-4) {
            lg[k] = log((l + r) / 2);
        } else {
            lg[k] = (ll + rr) / 2;
        }
        dfs(k * 2 + 0, l, (l + r) / 2, ll, lg[k]);
        dfs(k * 2 + 1, (l + r) / 2, r, lg[k], rr);
    }
}

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

    dfs(1, L, R, LL, RR);

    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;
            }
        }
        double s = (logR - logL) / (r - l);
        double ans = (logT + s * l * b - logL * b) / (s * b + a);
        printf("%.9f\n", exp(ans));
    }
}
0