結果

問題 No.456 Millions of Submits!
ユーザー pekempeypekempey
提出日時 2016-12-08 05:51:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 633 ms / 4,500 ms
コード長 1,762 bytes
コンパイル時間 1,029 ms
コンパイル使用メモリ 68,696 KB
実行使用メモリ 6,204 KB
最終ジャッジ日時 2023-09-05 12:20:35
合計ジャッジ時間 9,046 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,888 KB
testcase_01 AC 6 ms
6,016 KB
testcase_02 AC 6 ms
5,828 KB
testcase_03 AC 5 ms
5,824 KB
testcase_04 AC 5 ms
5,796 KB
testcase_05 AC 6 ms
5,796 KB
testcase_06 AC 6 ms
6,204 KB
testcase_07 AC 6 ms
5,928 KB
testcase_08 AC 6 ms
5,800 KB
testcase_09 AC 12 ms
6,008 KB
testcase_10 AC 12 ms
5,932 KB
testcase_11 AC 68 ms
6,032 KB
testcase_12 AC 633 ms
5,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cassert>
using namespace std;

#define getchar getchar_unlocked
#define putchar putchar_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;
}

void out(double x) {
    static char buf[20];
    sprintf(buf, "%.9f", x);
    for (int i = 0; buf[i] != '\0'; i++) {
        putchar(buf[i]);
    }
    putchar('\n');
}

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

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

    const double dx = R / (1 << H);

    const double logDX = log(R) - H * log(2);
    const double log00001 = -4 * log(10);

    for (int i = 0; i <= N; i++) {
        double tmp = log(i);
        lg[i] = tmp + logDX;
        lgt[i] = tmp + log00001;
    }

    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;
        double logT = lgt[c * 10000 + d];
        if (b == 0) {
            out(exp(logT / a));
            continue;
        }
        if (a == 0) {
            out(exp(exp(logT / b)));
            continue;
        }
        int l = 0;
        int r = N;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            (a * mid * dx + b * lg[mid] >= logT ? r : l) = mid;
        }
        double s = (lg[r] - lg[l]) / dx;
        double ans = (logT + s * b * l * dx - lg[l] * b) / (s * b + a);
        out(exp(ans));
    }
}
0