QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#436567 | #8785. Fake Coin and Lying Scales | ucup-team1198# | WA | 26ms | 4204kb | C++20 | 1.4kb | 2024-06-09 01:53:58 | 2024-06-09 01:54:01 |
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 = 500;
void solve() {
int n, k;
cin >> n >> k;
ld cur = 0;
int len = (n + D - 1) / D;
k = min(k, n);
for (int i = 0; i <= k; i += len) {
int L = i, R = min(k + 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: 0ms
memory: 4204kb
input:
2 100 0 100 1
output:
109.16808168625102837268 105.85895694123772159401
result:
ok q=0 (2 test cases)
Test #2:
score: 0
Accepted
time: 26ms
memory: 4096kb
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:
20.09444326417138171337 4.90586136619895540889 5.14319466133248681672 4.65456831821047956055 23.79448628853396385807 4.18990134020424420669 32.22847109632190409911 16.81541044029399500914 5.24224099071624038970 25.76859798203561524588 6.46762734691642293683 4.56494130693933897192 5.38951916577060785...
result:
ok q=0 (10000 test cases)
Test #3:
score: 0
Accepted
time: 0ms
memory: 4160kb
input:
1 10000 0
output:
10985.42973950053783482872
result:
ok q=0 (1 test case)
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 4108kb
input:
1 10000 10
output:
10981.93225489942415151745
result:
wrong answer WA (test case 1)