QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#168603#5050. Valueabsinthe#Compile Error//C++201.5kb2023-09-08 17:46:112023-09-08 17:46:13

Judging History

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

  • [2023-09-08 17:46:13]
  • 评测
  • [2023-09-08 17:46:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    vector<vector<int>> ls(n + 1);
    vector<int> done(n + 1);
    for (int i = 1; i <= n; i++) {
        if (done[i])continue;
        long long j = 1;
        while (j * i <= n) {
            j *= i;
            ls[i].push_back(j - 1);
            done[j]=1;
            if (i == 1) break;
        }
    }
    long long ans = 0;
    for (int cur = 1; cur <= n; cur++) {
        if (ls[cur].empty()) continue;
        int n = ls[cur].size();
        long long best = 0;
        for (int mask = 1; mask < (1 << n); mask++) {
            long long score = 0;
            for (int i = 0; i < n; i++) {
                if ((mask >> i) & 1) {
                    score += a[ls[cur][i]];
                    for (int j = 0; j < i; j++) {
                        if ((mask >> j) & 1) {
                            if ((i + 1) % (j + 1) == 0) {
                                
                                score -= b[ls[cur][i]];
                                ok=1;
                            }
                        }
                    }
                }
            }
            // cout <<cur<<' '<< mask <<' '<<score<<'\n';
            best = max(best, score);
        }
        ans += best;
    }
    cout << ans << '\n';
}

Details

answer.code: In function ‘int main()’:
answer.code:37:33: error: ‘ok’ was not declared in this scope
   37 |                                 ok=1;
      |                                 ^~