結果

問題 No.456 Millions of Submits!
ユーザー pekempeypekempey
提出日時 2016-12-08 07:37:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,494 bytes
コンパイル時間 3,002 ms
コンパイル使用メモリ 181,956 KB
実行使用メモリ 5,296 KB
最終ジャッジ日時 2023-09-05 12:28:46
合計ジャッジ時間 4,930 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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")
#include <bits/stdc++.h>
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(int n) {
    int res[11], i = 0;
    do { res[i++] = n % 10, n /= 10; } while (n);
    while (i) putchar(res[--i] + '0');
}

void out2(int n) {
    int res[11], i = 0;
    for (int j = 0; j < 9; j++) {
        res[i++] = n % 10;
        n /= 10;
    }
    while (i) {
        putchar(res[--i] + '0');
    }
}

void outDouble(double x) {
    int t = x;
    out(t);
    putchar('.');
    out2(int((x - t) * 1e9));
    putchar('\n');
}

const int H = 17;
const int N = 1 << H;
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);

double lg[N + 1];
bool prime[N + 1];

void sieve() {
    lg[0] = log(0);
    for (int i = 2; i <= N; i++) {
        if (!prime[i]) {
            double g = log(i);
            for (long long j = i; j < N; j *= i) {
                for (long long k = j; k < N; k += j) {
                    prime[k] = true;
                    lg[k] += g;
                }
            }
        }
    }
    for (int i = 0; i <= N; i++) {
        lg[i] += logDX;
    }
}

double elapsed() {
    static clock_t curr;
    clock_t prev = curr;
    curr = clock();
    return (double)(curr - prev) / CLOCKS_PER_SEC * 1000;
}

int main() {
    elapsed();
    int m = in();
    sieve();
    while (m--) {
        int a = in();
        int b = in();
        int c = in();
        int d = dot ? in() : 0;
        double t = c + 1e-4 * d;
        double logT = lg[c * 10000 + d] - logDX + log00001;
        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);
        outDouble(exp(ans));
    }
}
0