QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#695463#9426. Relearn through ReviewCharlie983Compile Error//C++14709b2024-10-31 20:05:362024-10-31 20:05:41

Judging History

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

  • [2024-10-31 20:05:41]
  • 评测
  • [2024-10-31 20:05:36]
  • 提交

answer

void solve() {
    int n = read(), k = read();

    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
        a[i] = read();
    }

    vector<int> pre(n + 1), suf(n + 2);
    for (int i = 1; i <= n; i++) {
        pre[i] = std::__gcd(pre[i - 1], a[i]);
    }
    for (int i = n; i >= 1; i--) {
        suf[i] = std::__gcd(suf[i + 1], a[i]);
    }

    int ans = pre[n];

    for (int i = 1; i <= n; i++) {
        if (pre[i] == pre[i - 1]) continue;

        int g = 0;

        for (int j = i; j <= n; j++) {
            g = std::__gcd(g, a[j] + k);
            ans = max(ans, std::__gcd(pre[i - 1], std::__gcd(g, suf[j + 1])));
        }
    }
    cout << ans << '\n';
}

Details

answer.code: In function ‘void solve()’:
answer.code:2:13: error: ‘read’ was not declared in this scope
    2 |     int n = read(), k = read();
      |             ^~~~
answer.code:4:5: error: ‘vector’ was not declared in this scope
    4 |     vector<int> a(n + 1);
      |     ^~~~~~
answer.code:4:12: error: expected primary-expression before ‘int’
    4 |     vector<int> a(n + 1);
      |            ^~~
answer.code:6:9: error: ‘a’ was not declared in this scope
    6 |         a[i] = read();
      |         ^
answer.code:9:12: error: expected primary-expression before ‘int’
    9 |     vector<int> pre(n + 1), suf(n + 2);
      |            ^~~
answer.code:11:9: error: ‘pre’ was not declared in this scope
   11 |         pre[i] = std::__gcd(pre[i - 1], a[i]);
      |         ^~~
answer.code:11:23: error: ‘__gcd’ is not a member of ‘std’
   11 |         pre[i] = std::__gcd(pre[i - 1], a[i]);
      |                       ^~~~~
answer.code:11:41: error: ‘a’ was not declared in this scope
   11 |         pre[i] = std::__gcd(pre[i - 1], a[i]);
      |                                         ^
answer.code:14:9: error: ‘suf’ was not declared in this scope
   14 |         suf[i] = std::__gcd(suf[i + 1], a[i]);
      |         ^~~
answer.code:14:23: error: ‘__gcd’ is not a member of ‘std’
   14 |         suf[i] = std::__gcd(suf[i + 1], a[i]);
      |                       ^~~~~
answer.code:14:41: error: ‘a’ was not declared in this scope
   14 |         suf[i] = std::__gcd(suf[i + 1], a[i]);
      |                                         ^
answer.code:17:15: error: ‘pre’ was not declared in this scope
   17 |     int ans = pre[n];
      |               ^~~
answer.code:25:22: error: ‘__gcd’ is not a member of ‘std’
   25 |             g = std::__gcd(g, a[j] + k);
      |                      ^~~~~
answer.code:25:31: error: ‘a’ was not declared in this scope
   25 |             g = std::__gcd(g, a[j] + k);
      |                               ^
answer.code:25:38: error: ‘k’ was not declared in this scope
   25 |             g = std::__gcd(g, a[j] + k);
      |                                      ^
answer.code:26:33: error: ‘__gcd’ is not a member of ‘std’
   26 |             ans = max(ans, std::__gcd(pre[i - 1], std::__gcd(g, suf[j + 1])));
      |                                 ^~~~~
answer.code:26:56: error: ‘__gcd’ is not a member of ‘std’
   26 |             ans = max(ans, std::__gcd(pre[i - 1], std::__gcd(g, suf[j + 1])));
      |                                                        ^~~~~
answer.code:26:65: error: ‘suf’ was not declared in this scope
   26 |             ans = max(ans, std::__gcd(pre[i - 1], std::__gcd(g, suf[j + 1])));
      |                                                                 ^~~
answer.code:26:19: error: ‘max’ was not declared in this scope
   26 |             ans = max(ans, std::__gcd(pre[i - 1], std::__gcd(g, suf[j + 1])));
      |                   ^~~
answer.code:29:5: error: ‘cout’ was not declared in this scope
   29 |     cout << ans << '\n';
      |     ^~~~