QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#555426#8708. PortalBucketsmithCompile Error//C++20999b2024-09-09 23:03:542024-09-09 23:03:55

Judging History

This is the latest submission verdict.

  • [2024-09-09 23:03:55]
  • Judged
  • [2024-09-09 23:03:54]
  • Submitted

answer

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

#define int long long

const int N = 1e5 + 10;
int n, x[N], y[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for(int i = 1; i <= n; i ++)
        cin >> x[i] >> y[i];
    
    int px = 0, py = 0;
    for(int i = n; i >= 1; i --) {
        x[i] -= x[1];
        y[i] -= y[1];
        if(x[i] < 0) {
            x[i] = -x[i];
            y[i] = -y[i];
        }
        if(x[i]) {
            px = x[i];
            py = y[i];
        }
    }
    
    if(!px) {
        cout << "-1\n";
        return 0;
    }

    int dy = 0;

    for(int i = 2; i <= n; i ++) {
        while(x[i] > 0) {
            int p = px / x[i];
            px -= p * x[i];
            py -= p * y[i];
            swap(px, x[i]);
            swap(py, y[i]);
        }
        if(y[i]) dy = gcd(abs(y[i]), dy);
    }

    if(!dy) cout << "-1\n";
    else cout << abs(1ll * dy * px) << "\n";
}

详细

cc1plus: error: ‘::main’ must return ‘int’