QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#227326#6801. BlackjackjzhWA 0ms7984kbC++231.1kb2023-10-27 12:22:272023-10-27 12:22:27

Judging History

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

  • [2023-10-27 12:22:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:7984kb
  • [2023-10-27 12:22:27]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

using db = double;

const int maxn = 510;
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 = 1 ; 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: 100
Accepted
time: 0ms
memory: 7984kb

input:

5 2 4
1 1 1 5 5

output:

0.10000000000000000555111512312578270211815834045410

result:

ok found '0.1000000', expected '0.1000000', error '0.0000000'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 7748kb

input:

5 2 4
1 1 1 3 5

output:

0.25000000000000000000000000000000000000000000000000

result:

wrong answer 1st numbers differ - expected: '0.4500000', found: '0.2500000', error = '0.2000000'