QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#746864 | #9752. 覆盖一个环 | jiangly (Lingyu Jiang) | AC ✓ | 51ms | 3932kb | C++23 | 833b | 2024-11-14 15:45:31 | 2024-11-14 15:45:32 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;
using F = long double;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout << std::fixed << std::setprecision(10);
int N, L;
std::cin >> N >> L;
F ans = 0;
for (int s = 1; s < (1 << N); s++) {
int c = 0;
int k = __builtin_ctz(s);
int r = k;
for (int i = k + 1; i < N; i++) {
if (s >> i & 1) {
c += std::max(0, i - r - L);
r = i;
}
}
c += std::max(0, k + N - r - L);
ans += (__builtin_parity(s) ? 1 : -1) * F(N) / (N - c);
}
std::cout << ans << "\n";
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3788kb
input:
3 2
output:
2.5000000000
result:
ok found '2.500000000', expected '2.500000000', error '0.000000000'
Test #2:
score: 0
Accepted
time: 51ms
memory: 3896kb
input:
20 20
output:
1.0000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #3:
score: 0
Accepted
time: 51ms
memory: 3856kb
input:
20 19
output:
2.0526315789
result:
ok found '2.052631579', expected '2.052631579', error '0.000000000'
Test #4:
score: 0
Accepted
time: 50ms
memory: 3748kb
input:
20 1
output:
71.9547931429
result:
ok found '71.954793143', expected '71.954793143', error '0.000000000'
Test #5:
score: 0
Accepted
time: 12ms
memory: 3688kb
input:
18 17
output:
2.0588235294
result:
ok found '2.058823529', expected '2.058823529', error '0.000000000'
Test #6:
score: 0
Accepted
time: 12ms
memory: 3800kb
input:
18 16
output:
2.1911764706
result:
ok found '2.191176471', expected '2.191176471', error '0.000000000'
Test #7:
score: 0
Accepted
time: 9ms
memory: 3816kb
input:
18 15
output:
2.3500000000
result:
ok found '2.350000000', expected '2.350000000', error '0.000000000'
Test #8:
score: 0
Accepted
time: 12ms
memory: 3788kb
input:
18 14
output:
2.5428571429
result:
ok found '2.542857143', expected '2.542857143', error '0.000000000'
Test #9:
score: 0
Accepted
time: 12ms
memory: 3900kb
input:
18 13
output:
2.7802197802
result:
ok found '2.780219780', expected '2.780219780', error '0.000000000'
Test #10:
score: 0
Accepted
time: 12ms
memory: 3932kb
input:
18 2
output:
30.0428145384
result:
ok found '30.042814538', expected '30.042814538', error '0.000000000'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
1 1
output:
1.0000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Extra Test:
score: 0
Extra Test Passed