QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#695484#9426. Relearn through ReviewCharlie983Compile Error//C++14839b2024-10-31 20:07:592024-10-31 20:08:00

Judging History

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

  • [2024-10-31 20:08:00]
  • 评测
  • [2024-10-31 20:07:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define endl '\n'
const int N = 1e6 + 10,M=210;
const int inf=0x3f3f3f3f,mod=998244353;
void solve() {
    int n,k;
    cin>>n>>k;

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

    vector<int> pre(n + 1), suf(n + 2);
    for (int i = 1; i <= n; i++) {
        pre[i] = __gcd(pre[i - 1], a[i]);
    }
    for (int i = n; i >= 1; i--) {
        suf[i] = __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 = __gcd(g, a[j] + k);
            ans = max(ans, __gcd(pre[i - 1], __gcd(g, suf[j + 1])));
        }
    }
    cout << ans << '\n';
}

Details

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status