QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#387404#6748. Spin the Wheelk1nsomCompile Error//C++17515b2024-04-12 14:41:542024-04-12 14:41:54

Judging History

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

  • [2024-04-12 14:41:54]
  • 评测
  • [2024-04-12 14:41:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define N 200005
#define int long long
#define endl '\n'
int ans = 0, n, gc, a[N];
signed main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    gc = (a[2] - a[1] + n - 1) % n + 1; // 公差
    for (int i = 2; i <= n; i++)
        if ((a[i % n + 1] - a[i] + n - 1) % n + 1 != gc)
        {
            cout << -1;
            // cout << i;
            return 0;
        }
    cout << ((a[1] != 0) + gc);
    return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:20:19: error: expected ‘)’ before ‘!’
   20 |     cout << ((a[1] != 0) + gc);
      |              ~    ^~~
      |                   )
answer.code:20:32: error: expected ‘)’ before ‘;’ token
   20 |     cout << ((a[1] != 0) + gc);
      |             ~                  ^
      |                                )