QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#227176 | #6801. Blackjack | jzh | WA | 5ms | 11828kb | C++23 | 1.2kb | 2023-10-27 00:54:10 | 2023-10-27 00:54:11 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using db = long double;
const int maxn = 505;
db dp[maxn][maxn], ndp[maxn][maxn];
int vec[maxn];
void solve() {
int n, a, b; cin >> n >> a >> b;
for(int i = 1 ; i <= n ; i ++) cin >> vec[i];
dp[0][0] = 1;
for(int i = 1 ; i <= n ; i ++) {
memset(ndp, 0, sizeof(ndp));
for(int x = 0 ; x < i ; x ++) {
for(int y = 0 ; y <= b ; y ++) {
ndp[x][y] += dp[x][y];
if(y+vec[i]<=b) ndp[x+1][y + vec[i]] += dp[x][y] * (x+1) / (n-x);
}
}
for(int x = 0 ; x <= n ; x ++) {
for(int y = 0 ; y <= b ; y ++) {
cout << dp[x][y] << ' ';
}
cout << endl;
}
memcpy(dp, ndp, sizeof(ndp));
}
db ans = 0;
for(int i = 1 ; i <= n ; i ++) {
memcpy(ndp, dp, sizeof(dp));
for(int x = 0 ; x < n ; x ++) {
for(int y = 0 ; y <= b ; y ++) {
ndp[x+1][y+vec[i]] -= ndp[x][y] * (x+1) / (n-x);
}
}
db temp = 0;
for(int x = 0 ; x <= n-1 ; x ++) {
for(int y = 0 ; y <= a ; y ++) {
if(y+vec[i]>a and y+vec[i]<=b) {
temp += ndp[x][y] / (n-x);
}
}
}
ans += temp;
}
cout << fixed << setprecision(50) << ans << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 5ms
memory: 11828kb
input:
5 2 4 1 1 1 5 5
output:
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0.2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0.4 0 0 0 0 0 0.1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0.6 0 0 0 0 0 0.3 0 0 0 0 0 0.1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0.6 0 0 0 ...
result:
wrong answer 1st numbers differ - expected: '0.1000000', found: '1.0000000', error = '0.9000000'