QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#841092 | #5646. Uniform Chemistry | shinonome_ena# | AC ✓ | 2ms | 4292kb | C++23 | 834b | 2025-01-03 13:09:11 | 2025-01-03 13:09:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MAX 110
int S[MAX];
ld dp[MAX][MAX];
ld sdp[MAX][MAX];
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
cout << fixed;
cout.precision(20);
int N, M;
cin >> N >> M;
int i, j, k;
for (i = 1; i <= M; i++) cin >> S[i], S[i] = N - S[i];
dp[0][0] = 1;
sdp[0][0] = 1;
for (i = 1; i <= N; i++) {
for (j = 0; j < i; j++) {
for (k = 0; k <= N; k++) dp[i][k + 1] += dp[j][k] / (ld)i;
}
for (j = i; j >= 0; j--) sdp[i][j] = sdp[i][j + 1] + dp[i][j];
}
for (i = 1; i <= M; i++) {
ld sum = 0;
for (j = 0; j <= S[i]; j++) {
ld mul = dp[S[i]][j];
for (k = 1; k <= M; k++) {
if (i == k) continue;
mul *= sdp[S[k]][j];
}
sum += mul;
}
cout << sum << ' ';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3904kb
input:
2 3 1 1 1
output:
1.00000000000000000000 1.00000000000000000000 1.00000000000000000000
result:
ok 3 numbers, max absolute error 0
Test #2:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
3 3 1 1 2
output:
0.50000000000000000000 0.50000000000000000000 1.00000000000000000000
result:
ok 3 numbers, max absolute error 0
Test #3:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
3 3 1 1 1
output:
0.62500000000000000000 0.62500000000000000000 0.62500000000000000000
result:
ok 3 numbers, max absolute error 0
Test #4:
score: 0
Accepted
time: 2ms
memory: 4244kb
input:
100 7 1 2 4 8 16 32 64
output:
0.17859346862375033464 0.17981045473107379642 0.18230677063927824725 0.18756536558781155889 0.19930042952939319789 0.22935632241384935481 0.34872251794410225533
result:
ok 7 numbers, max absolute error 4.70606804e-10
Test #5:
score: 0
Accepted
time: 0ms
memory: 4292kb
input:
100 10 28 58 38 53 1 19 66 60 68 31
output:
0.13203124473441064699 0.19547837544457064728 0.14727832600343695871 0.18016945052977996735 0.10449528336206387845 0.12111203297217177253 0.22774417556729385907 0.20250682431319990347 0.23792489325136871378 0.13620726884859008363
result:
ok 10 numbers, max absolute error 1.11022302e-16
Test #6:
score: 0
Accepted
time: 2ms
memory: 4244kb
input:
100 10 86 50 88 42 88 20 29 83 89 34
output:
0.26335354511633936816 0.09601684555797174953 0.29734628468613810343 0.08526676116679067753 0.29734628468613810343 0.06586164758713535996 0.07249706956582600224 0.22598103884075662429 0.31842780574297111588 0.07687560852812799045
result:
ok 10 numbers, max absolute error 1.66533454e-16
Test #7:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
2 1 1
output:
1.00000000000000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3872kb
input:
10 3 4 6 7
output:
0.37213541666666666668 0.52349537037037037040 0.66784336419753086422
result:
ok 3 numbers, max absolute error 1.11022302e-16
Test #9:
score: 0
Accepted
time: 1ms
memory: 3936kb
input:
20 10 6 6 9 3 14 15 13 8 6 11
output:
0.15191773720888006942 0.15191773720888006942 0.18714646918867133752 0.12842754310202011705 0.31623420335559153960 0.37043457030763186861 0.27669775335329040050 0.17358207630566267412 0.15191773720888006942 0.22261336267712522823
result:
ok 10 numbers, max absolute error 1.11022302e-16
Test #10:
score: 0
Accepted
time: 2ms
memory: 4196kb
input:
99 2 40 55
output:
0.53661402494642751292 0.62959269381274074934
result:
ok 2 numbers, max absolute error 5.55111512e-16
Test #11:
score: 0
Accepted
time: 2ms
memory: 4192kb
input:
99 9 86 68 85 83 75 70 71 73 70
output:
0.29457411708976180759 0.14923449022955953114 0.27802947617845735035 0.25051406574653363641 0.18243542993531475792 0.15726387538773390459 0.16165785003702031912 0.17133817158708363001 0.15726387538773390460
result:
ok 9 numbers, max absolute error 1.66533454e-16