This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
long long N, A, B, C, X, Y, OX, OY;
int main() {
cin >> N >> OX >> OY; N--;
while(N--) {
cin >> X >> Y;
X -= OX; Y -= OX;
while(X != 0) {
long long R = A / X;
A -= R * X; B -= R * Y;
swap(A, X); swap(B, Y);
}
while(Y != 0) {
long long R = C / Y;
C -= R * Y;
swap(C, Y);
}
if(C != 0) { B %= C; }
}
if(A == 0 || C == 0) cout << -1 << endl;
else cout << abs(A * C) << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |