QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#250243 | #5646. Uniform Chemistry | MovingUp | AC ✓ | 1ms | 4056kb | C++23 | 1.1kb | 2023-11-12 23:57:57 | 2023-11-12 23:57:58 |
Judging History
answer
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
int main() {
/**
*
* P(X_b >= a) = sum(P(X_c >= a - 1) * (1 / (n - b)))
*
*/
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<vector<double>> probs(n + 1, vector<double>(n, 0.0));
probs[n][0] = 1.0;
for (int j = 1; j < n; j++) {
for (int i = n - 1; i >= 1; i--) {
int totalRem = n - i;
for (int k = i + 1; k <= n; k++) {
probs[i][j] += probs[k][j - 1] * (1.0 / totalRem);
}
}
}
vector<int> a(m);
for (int i = 0; i < m; i++) {
cin >> a[i];
}
cout << fixed << setprecision(9);
for (int i = 0; i < m; i++) {
double ans = 0.0;
for (int p = 0; p < n; p++) {
double curr = probs[a[i]][p];
for (int j = 0; j < m; j++) {
if (i == j)
continue;
double sum = 0.0;
for (int k = p; k < n; k++) {
sum += probs[a[j]][k];
}
curr *= sum;
}
ans += curr;
}
cout << ans << " ";
}
cout << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4056kb
input:
2 3 1 1 1
output:
1.000000000 1.000000000 1.000000000
result:
ok 3 numbers, max absolute error 0
Test #2:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
3 3 1 1 2
output:
0.500000000 0.500000000 1.000000000
result:
ok 3 numbers, max absolute error 0
Test #3:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
3 3 1 1 1
output:
0.625000000 0.625000000 0.625000000
result:
ok 3 numbers, max absolute error 0
Test #4:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
100 7 1 2 4 8 16 32 64
output:
0.178593469 0.179810455 0.182306771 0.187565366 0.199300430 0.229356322 0.348722518
result:
ok 7 numbers, max absolute error 0
Test #5:
score: 0
Accepted
time: 1ms
memory: 3960kb
input:
100 10 28 58 38 53 1 19 66 60 68 31
output:
0.132031245 0.195478375 0.147278326 0.180169451 0.104495283 0.121112033 0.227744176 0.202506824 0.237924893 0.136207269
result:
ok 10 numbers, max absolute error 4.7022003e-10
Test #6:
score: 0
Accepted
time: 1ms
memory: 3960kb
input:
100 10 86 50 88 42 88 20 29 83 89 34
output:
0.263353545 0.096016846 0.297346285 0.085266761 0.297346285 0.065861648 0.072497070 0.225981039 0.318427806 0.076875609
result:
ok 10 numbers, max absolute error 4.71872028e-10
Test #7:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
2 1 1
output:
1.000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3980kb
input:
10 3 4 6 7
output:
0.372135417 0.523495370 0.667843364
result:
ok 3 numbers, max absolute error 3.70370512e-10
Test #9:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
20 10 6 6 9 3 14 15 13 8 6 11
output:
0.151917737 0.151917737 0.187146469 0.128427543 0.316234203 0.370434570 0.276697753 0.173582076 0.151917737 0.222613363
result:
ok 10 numbers, max absolute error 3.55591556e-10
Test #10:
score: 0
Accepted
time: 1ms
memory: 3908kb
input:
99 2 40 55
output:
0.536614025 0.629592694
result:
ok 2 numbers, max absolute error 1.87258653e-10
Test #11:
score: 0
Accepted
time: 1ms
memory: 3900kb
input:
99 9 86 68 85 83 75 70 71 73 70
output:
0.294574117 0.149234490 0.278029476 0.250514066 0.182435430 0.157263875 0.161657850 0.171338172 0.157263875
result:
ok 9 numbers, max absolute error 4.1291634e-10