結果
問題 | No.456 Millions of Submits! |
ユーザー | pekempey |
提出日時 | 2016-12-08 06:45:22 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,616 bytes |
コンパイル時間 | 931 ms |
コンパイル使用メモリ | 84,720 KB |
実行使用メモリ | 38,912 KB |
最終ジャッジ日時 | 2024-06-23 07:59:27 |
合計ジャッジ時間 | 3,538 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
5,248 KB |
testcase_01 | AC | 5 ms
5,376 KB |
testcase_02 | AC | 4 ms
5,376 KB |
testcase_03 | AC | 5 ms
5,376 KB |
testcase_04 | AC | 4 ms
5,376 KB |
testcase_05 | AC | 4 ms
5,376 KB |
testcase_06 | AC | 5 ms
5,376 KB |
testcase_07 | AC | 5 ms
5,376 KB |
testcase_08 | AC | 5 ms
5,376 KB |
testcase_09 | AC | 10 ms
5,376 KB |
testcase_10 | AC | 10 ms
5,504 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
ソースコード
#include <iostream> #include <cstdio> #include <cmath> #include <cassert> #include <vector> #include <algorithm> using namespace std; #define getchar getchar_unlocked #define putchar putchar_unlocked bool dot; 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]; vector<int> gr[11][11]; 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'); } 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; } } int binSearch(int a, int b, double logT) { 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; } return l; } int main() { int m = in(); sieve(); vector<int> a(m), b(m), c(m), d(m); for (int i = 0; i < m; i++) { a[i] = in(); b[i] = in(); c[i] = in(); d[i] = dot ? in() : 0; c[i] = c[i] * 10000 + d[i]; } vector<int> it(m); for (int i = 0; i < m; i++) { it[i] = i; } sort(it.begin(), it.end(), [&](int i, int j) { return c[i] < c[j]; }); for (int i : it) { gr[a[i]][b[i]].emplace_back(i); } vector<double> ans(m); for (int a = 0; a <= 10; a++) { for (int b = 0; b <= 10; b++) { if (gr[a][b].empty()) { continue; } if (b == 0) { for (int i : gr[a][b]) { const double logT = lg[c[i]] - logDX + log00001; ans[i] = exp(logT / a); } continue; } if (a == 0) { for (int i : gr[a][b]) { const double logT = lg[c[i]] - logDX + log00001; ans[i] = exp(exp(logT / b)); } continue; } if (gr[a][b].size() <= 500) { for (int i : gr[a][b]) { const double logT = lg[c[i]] - logDX + log00001; int l = binSearch(a, b, logT); double s = (lg[l + 1] - lg[l]) / dx; ans[i] = exp((logT + s * b * l * dx - lg[l] * b) / (s * b + a)); } } else { int l = 1; for (int i : gr[a][b]) { const double logT = lg[c[i]] - logDX + log00001; while (l < N && a * l * dx + b * lg[l] < logT) { l++; } double s = (lg[l + 1] - lg[l]) / dx; ans[i] = exp((logT + s * b * l * dx - lg[l] * b) / (s * b + a)); } } } } for (int i = 0; i < m; i++) { out(ans[i]); } }