# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1076608 | Arturgo | Portal (BOI24_portal) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
long long N,A,B,C,R,T,X,Y,OX,OY;
int main() {
scanf("%lld%lld%lld",&N,&OX,&OY);N--;
while(N--) {
scanf("%lld%lld",&X,&Y);
X -= OX; Y -= OY;
while(X) {
R=A/X;
A -= R * X; B -= R * Y;
T=A;A=X;X=T;
T=B;B=Y;Y=T;
}
while(Y) {
C%=Y;
T=Y;Y=C;C=T;
}
if(C != 0)B%=C;
}
if(A*C<0)A=-A;if(A==0||C==0)printf("-1");else printf("%lld",A*C);
}