QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#623543#9426. Relearn through ReviewTienKhoiCompile Error//Python31.4kb2024-10-09 12:59:072024-10-09 12:59:07

Judging History

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

  • [2024-10-09 12:59:07]
  • 评测
  • [2024-10-09 12:59:07]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FOD(i, a, b) for (int i = (a); i >= (b); i--)
#define bit(x, y) ((x) >> (y)) & 1
#define pb push_back
#define ll long long
#define ii pair<int, int>
#define f first
#define s second
#define M 1000000007
using namespace std;
const int N = 3e5 + 5;

int n, k;
int a[N], l[N], r[N];

void Inp()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if (fopen(".inp", "r"))
    {
        freopen(".inp", "r", stdin);
        freopen(".out", "w", stdout);
    }
}

void solve()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];

    l[0] = 0;
    for (int i = 1; i <= n; i++)
        l[i] = __gcd(l[i - 1], a[i]);
    
    r[n + 1] = 0;
    for (int i = n; i >= 1; i--)
        r[i] = __gcd(r[i + 1], a[i]);

    int ans = l[n];
    for (int i = 1; i <= n; i++)
    {
        if (i != 1 && l[i] >= l[i - 1])
            continue;

        int g = 0;
        for (int j = i; j <= n; j++)
        {
            
            g = __gcd(g, a[j] + k);
            ans = max(ans, __gcd(g, __gcd(l[i - 1], r[j + 1])));
        }
    }

    cout << ans << '\n';
}
signed main()
{
    Inp();
    int Case = 1;
    cin >> Case;
    while (Case--)
        solve();
    return 0;
}

详细

  File "answer.code", line 12
    using namespace std;
          ^^^^^^^^^
SyntaxError: invalid syntax