QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#790470#9426. Relearn through Reviewsnow_mikumikuCompile Error//C++141.4kb2024-11-28 12:26:512024-11-28 12:26:52

Judging History

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

  • [2024-11-28 12:26:52]
  • 评测
  • [2024-11-28 12:26:51]
  • 提交

answer

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

void solve()
{
    LL n, k, mx = 0, mn = 2e18;
    cin >> n >> k;
    vector <LL> A(n + 1);
    for(int i = 1; i <= n; i++) cin >> A[i];
    
    LL ans = A[1] + k;
    for(int i = 1; i <= n; i++) {
        ans = gcd(ans, A[i] + k);
    }

    LL GCD = A[1];
    for(int i = 1; i <= n; i++) {
        LL up = GCD;
        GCD = gcd(GCD, A[i]);
        if(up > GCD) {
            LL f = 1, res = A[i - 1];
            for(int j = i; j <= n; j++) {
               if(gcd(A[j] + k, res) < gcd(A[j], res)) f = 0;
               if(f) res = gcd(res, A[j] + k);
               else res = gcd(res, A[j]);
            }
            ans = max(ans, res);
        }
    }

    reverse(A.begin() + 1, A.end());
    GCD = A[1];
    for(int i = 1; i <= n; i++) {
        LL up = GCD;
        GCD = gcd(GCD, A[i]);
        if(up > GCD) {
            LL f = 1, res = A[i - 1];
            for(int j = i; j <= n; j++) {
               if(gcd(A[j] + k, res) < gcd(A[j], res)) f = 0;
               if(f) res = gcd(res, A[j] + k);
               else res = gcd(res, A[j]);
            }
            ans = max(ans, res);
        }
    }
    ans = max(ans, GCD);
    cout << ans << '\n';
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}

詳細信息

answer.code: In function ‘void solve()’:
answer.code:14:15: error: ‘gcd’ was not declared in this scope
   14 |         ans = gcd(ans, A[i] + k);
      |               ^~~
answer.code:20:15: error: ‘gcd’ was not declared in this scope
   20 |         GCD = gcd(GCD, A[i]);
      |               ^~~
answer.code:36:15: error: ‘gcd’ was not declared in this scope
   36 |         GCD = gcd(GCD, A[i]);
      |               ^~~