結果

問題 No.456 Millions of Submits!
ユーザー pekempeypekempey
提出日時 2016-12-08 22:45:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,594 ms / 4,500 ms
コード長 1,511 bytes
コンパイル時間 1,607 ms
コンパイル使用メモリ 166,324 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 21:15:40
合計ジャッジ時間 11,859 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 28 ms
4,376 KB
testcase_10 AC 28 ms
4,380 KB
testcase_11 AC 261 ms
4,380 KB
testcase_12 AC 2,594 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

bool dot;

int readInt() {
    int n, c;
    while ((c = getchar()) < '0');
    n = c - '0';
    while ((c = getchar()) >= '0') {
        n = n * 10 + c - '0';
    }
    dot = c == '.';
    return n;
}

void writeDouble(double x) {
    int a = x;
    int b = (x - a) * 1e9;
    int d[15];
    int i = 0;
    for (int j = 0; j < 9; j++) {
        d[i++] = b % 10 + '0';
        b /= 10;
    }
    d[i++] = '.';
    do {
        d[i++] = a % 10 + '0';
        a /= 10;
    } while (a > 0);
    while (i > 0) {
        putchar(d[--i]);
    }
    putchar('\n');
}

int main() {
    int m;
    cin >> m;
    while (m--) {
        int a = readInt();
        int b = readInt();
        int c = readInt();
        int d = dot ? readInt() : 0;
        double t = c + d * 1e-4;
        if (b == 0) {
            writeDouble(pow(t, 1.0 / a));
            continue;
        }
        if (a == 0) {
            writeDouble(exp(pow(t, 1.0 / b)));
            continue;
        }
        double r = 10;
        double l = 1;
        double logT = log(t);
        for (int ii = 0; ii < 40; ii++) {
            double mid = (l + r) / 2;
            double logN = log(mid);
            double loglogN = log(logN);
            if (a * logN + b * loglogN >= logT) {
                r = mid;
            } else {
                l = mid;
            }
        }
        writeDouble(r);
    }
}
0