QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#812374 | #5646. Uniform Chemistry | ucup-team3723# | AC ✓ | 1ms | 4260kb | C++17 | 1.3kb | 2024-12-13 14:51:04 | 2024-12-13 14:51:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define dbg(x) cerr << #x << ':' << (x) << endl;
#define ALL(x) x.begin(),x.end()
void solve() {
int n,m;
cin >> n >> m;
vector<int> a(m);
for (int i = 0; i < m; ++i) cin >> a[i];
vector<vector<ld>> prob(n + 1, vector<ld> (n + 1));
prob[n][0] = 1;
for (int i = 1; i <= n; ++i)
{
ld sum = 0;
for (int j = n - 1; j >= 0; --j)
{
sum += prob[j + 1][i - 1];
prob[j][i] = sum / (n - j);
}
}
// for (int i = 1; i <= n; ++i)
// {
// for (int j = 0; j <= n; ++j) cout << prob[i][j] << " \n"[j == n];
// }
vector<vector<ld>> s(n + 1);
for (int i = 1; i <= n; ++i) {
s[i].push_back(0);
partial_sum(ALL(prob[i]), back_inserter(s[i]));
}
for (int i = 0; i < m; ++i) {
ld ans = 0;
for (int j = 1; j <= n - a[i]; ++j) {
ld x = 1;
for (int k = 0; k < m; ++k) if (k != i) {
x *= s[a[k]].back() - s[a[k]][j];
}
ans += prob[a[i]][j] * x;
}
cout << fixed << setprecision(20) << ans << " \n"[i==m-1];
}
}
int main()
{
int t;
// cin >> t;
t = 1;
while (t--) solve();
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3764kb
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: 3992kb
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: 3772kb
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: 1ms
memory: 4200kb
input:
100 7 1 2 4 8 16 32 64
output:
0.17859346862375033468 0.17981045473107379646 0.18230677063927824734 0.18756536558781155892 0.19930042952939319794 0.22935632241384935484 0.34872251794410225541
result:
ok 7 numbers, max absolute error 4.70606804e-10
Test #5:
score: 0
Accepted
time: 1ms
memory: 4160kb
input:
100 10 28 58 38 53 1 19 66 60 68 31
output:
0.13203124473441064707 0.19547837544457064743 0.14727832600343695877 0.18016945052977996747 0.10449528336206387852 0.12111203297217177257 0.22774417556729385921 0.20250682431319990362 0.23792489325136871391 0.13620726884859008371
result:
ok 10 numbers, max absolute error 1.11022302e-16
Test #6:
score: 0
Accepted
time: 1ms
memory: 4260kb
input:
100 10 86 50 88 42 88 20 29 83 89 34
output:
0.26335354511633936824 0.09601684555797174957 0.29734628468613810343 0.08526676116679067752 0.29734628468613810343 0.06586164758713535997 0.07249706956582600227 0.22598103884075662430 0.31842780574297111597 0.07687560852812799044
result:
ok 10 numbers, max absolute error 1.66533454e-16
Test #7:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
2 1 1
output:
1.00000000000000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
10 3 4 6 7
output:
0.37213541666666666668 0.52349537037037037035 0.66784336419753086422
result:
ok 3 numbers, max absolute error 1.11022302e-16
Test #9:
score: 0
Accepted
time: 0ms
memory: 4024kb
input:
20 10 6 6 9 3 14 15 13 8 6 11
output:
0.15191773720888006939 0.15191773720888006939 0.18714646918867133748 0.12842754310202011699 0.31623420335559153954 0.37043457030763186853 0.27669775335329040042 0.17358207630566267407 0.15191773720888006941 0.22261336267712522813
result:
ok 10 numbers, max absolute error 1.11022302e-16
Test #10:
score: 0
Accepted
time: 1ms
memory: 4220kb
input:
99 2 40 55
output:
0.53661402494642751286 0.62959269381274074950
result:
ok 2 numbers, max absolute error 5.55111512e-16
Test #11:
score: 0
Accepted
time: 1ms
memory: 4072kb
input:
99 9 86 68 85 83 75 70 71 73 70
output:
0.29457411708976180762 0.14923449022955953114 0.27802947617845735041 0.25051406574653363647 0.18243542993531475794 0.15726387538773390457 0.16165785003702031909 0.17133817158708363001 0.15726387538773390457
result:
ok 9 numbers, max absolute error 1.66533454e-16