QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#227335#6801. BlackjackjzhWA 1ms3712kbC++231.1kb2023-10-27 12:30:182023-10-27 12:30:18

Judging History

你现在查看的是最新测评结果

  • [2023-10-27 12:30:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3712kb
  • [2023-10-27 12:30:18]
  • 提交

answer

#include <algorithm>
#include<bits/stdc++.h>

using namespace std;

using db = double;

const int maxn = 510;

void solve() {
	int n, a, b; cin >> n >> a >> b;
	vector<int>vec(n);
	for(int i = 0 ; i < n ; i ++) cin >> vec[i];

	vector<vector<db>>dp(n+1, vector<db>(b+1));
	auto ndp = dp;

	dp[0][0] = 1;

	for(int i = 0 ; i < n ; i ++) {	
		for(auto &v: ndp) fill(begin(v), end(v), 0);
		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);
			}
		}
		dp = ndp;
	}

	db ans = 0;
	for(int i = 0 ; i < n ; i ++) {
		ndp = 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 ; x ++) {
			for(int y = max(0, a-vec[i]+1) ; 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: 1ms
memory: 3712kb

input:

5 2 4
1 1 1 5 5

output:

0.00000000000000000000000000000000000000000000000000

result:

wrong answer 1st numbers differ - expected: '0.1000000', found: '0.0000000', error = '0.1000000'