QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#227175#6801. BlackjackjzhCompile Error//Python31.2kb2023-10-27 00:53:492023-10-27 00:53:50

Judging History

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

  • [2023-10-27 00:53:50]
  • 评测
  • [2023-10-27 00:53:49]
  • 提交

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;
}

详细

  File "answer.code", line 3
    using namespace std;
          ^^^^^^^^^
SyntaxError: invalid syntax