QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#436580 | #8785. Fake Coin and Lying Scales | ucup-team1198# | WA | 12ms | 4080kb | C++20 | 1.4kb | 2024-06-09 01:57:04 | 2024-06-09 01:57:05 |
Judging History
answer
#include <map>
#include <set>
#include <array>
#include <cmath>
#include <deque>
#include <bitset>
#include <random>
#include <string>
#include <vector>
#include <cassert>
#include <complex>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ld = double;
const ld PI = atan2l(0, -1);
ld fact(int x) {
if (x == 0) return 0;
return log(2 * PI * x) / 2 + x * log(x) - x;
}
ld C(int n, int k) {
return fact(n) - fact(k) - fact(n - k);
}
ld add(ld p, ld q) {
if (p > q) swap(p, q);
return q + log(1 + exp(p - q));
}
const int D = 100;
void solve() {
int n, k;
cin >> n >> k;
ld cur = 0;
int len = (n + D - 1) / D;
k = min(k, n);
for (int i = k + 1; i <= n; i += len) {
int L = i, R = min(n + 1, i + len);
ld res = C(n, L);
if (R - L < 50) {
res += L * log(2) + log((1ll << (R - L)) - 1);
} else {
res += R * log(2);
}
cur = add(cur, res);
}
ld ans = log(3 * k + 1) + cur;
/// ans += n * log(3);
cout << ans << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout << fixed << setprecision(20);
int tst;
cin >> tst;
while (tst--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 4072kb
input:
2 100 0 100 1
output:
109.86420456950420998510 111.25049893062410433231
result:
ok q=0 (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 12ms
memory: 4080kb
input:
10000 32 6 45 98 67 57 35 70 29 3 22 81 59 12 48 16 63 69 99 36 60 36 32 47 73 91 81 30 7 7 71 57 38 60 35 19 92 40 3 17 21 71 54 62 95 67 60 50 10 20 19 80 64 73 10 21 70 97 84 3 26 22 38 47 37 38 31 91 11 37 73 17 75 98 8 74 73 60 87 10 94 48 35 73 18 14 88 25 61 54 39 59 100 90 70 98 73 21 92 11 ...
output:
38.10980185282380006129 4.91265488573605235700 70.18192349477898517307 4.66343909411206691829 34.17321548983107248887 4.20469261939096572434 68.43416246131671698549 56.63155608365634918755 5.24702407216048616334 113.45697085344176002764 70.42869172502493313459 4.57471097850338281887 5.39362754635236...
result:
wrong answer WA (test case 3)