QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#438657 | #8785. Fake Coin and Lying Scales | ucup-team1198 | WA | 10ms | 3980kb | C++14 | 1.2kb | 2024-06-10 21:28:36 | 2024-06-10 21:28:36 |
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 = long double;
const ld PI = atan2l(0, -1);
ld D(ld a, ld p) {
return a * logl(a / p) + (1 - a) * logl((1 - a) / (1 - p));
}
ld F(int n, ld p, int k) {
if (k == n) {
return logl(p) * n;
}
if (k == 0) {
return 0;
}
return -n * D((ld)k / n, p);
}
void solve() {
int n, k;
cin >> n >> k;
ld ans = logl(3 * k + 1);
k = min(k, n);
if (3ll * k <= 2ll * n) {
ans -= F(n, (ld)1 / 3, n - k);
} else {
ld p = F(n, (ld)2 / 3, k + 1);
p = logl(1 - expl(p));
ans -= p;
}
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: 3924kb
input:
2 100 0 100 1
output:
109.86122886681096913475 104.95422261188618041211
result:
ok q=0 (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 10ms
memory: 3980kb
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:
18.49866704752189240993 nan 5.14843382199484994079 nan 22.43766770764450627605 nan 30.31238466473466224189 14.98217518706975156292 nan 23.60797034397608865075 5.27408668160230788757 nan nan 19.31268666217311136962 nan 5.16600417537365691522 nan 5.21065469116068741024 15.15753632294498640196 nan nan ...
result:
wrong output format Expected double, but "nan" found (test case 2)