QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#227352#6801. BlackjackjzhCompile Error//C++141.7kb2023-10-27 12:58:572023-10-27 12:58:57

Judging History

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

  • [2023-10-27 12:58:57]
  • 评测
  • [2023-10-27 12:58:57]
  • 提交

answer

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

using namespace std;

using db = long double;

const int maxn = 510;

void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> vec(n+10);
    for (int i = 0; i < n; i++) cin >> vec[i];
    vector<vector<db>> dp(n + 10, vector<db>(b + 10, 0));
    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;
    }
    for (auto &v: ndp) fill(begin(v), end(v), 0);
    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);
            }
        }
        db temp = 0;
        for (int x = 0; x < n; x++) {
            db t1 = 0;
            for (int y = max(0, a - vec[i] + 1); y <= min(a, b - vec[i]); y++) {
                t1 += ndp[x][y];
            }
            temp += t1 / (n - x + 1e-9);
            if(temp > 1){
                cout <<" cur temp " << temp <<" in " << i <<","<< x <<','<< y << endl;
                return;
            }
        }
        ans += temp;
    }
    cout << fixed << setprecision(30) << (long double) ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:47:77: error: ‘y’ was not declared in this scope
   47 |                 cout <<" cur temp " << temp <<" in " << i <<","<< x <<','<< y << endl;
      |                                                                             ^