QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#227318 | #6801. Blackjack | jzh | WA | 6ms | 11748kb | C++23 | 1.2kb | 2023-10-27 12:11:00 | 2023-10-27 12:11:01 |
Judging History
answer
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx2","sse2","fma")
#include<bits/stdc++.h>
using namespace std;
using db = __float128;
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];
}
for(int y = 0 ; y <= b-vec[i] ; y ++) {
ndp[x+1][y + vec[i]] += dp[x][y] * (x+1) / (n-x);
}
}
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-vec[i] ; y ++) {
ndp[x+1][y+vec[i]] -= ndp[x][y] * (x+1) / (n-x);
}
}
for(int x = 0 ; x <= n-1 ; x ++) {
for(int y = max(0, a-vec[i]) ; y <= min(a, b-vec[i]) ; y ++) {
ans += ndp[x][y] / (n-x);
}
}
}
cout << fixed << setprecision(50) << (long double)ans << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 6ms
memory: 11748kb
input:
5 2 4 1 1 1 5 5
output:
0.40000000000000000000542101086242752217003726400435
result:
wrong answer 1st numbers differ - expected: '0.1000000', found: '0.4000000', error = '0.3000000'