# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1266286 | herominhsteve | Portal (BOI24_portal) | C++20 | 15 ms | 328 KiB |
#include <bits/stdc++.h>
#define el '\n'
#define FNAME "portal"
#define allof(x) x.begin(),x.end()
#define allof1(x) x.begin()+1,x.end()
#define mset(x,n) memset(x,(n),sizeof(x))
using namespace std;
const long long MOD = (long long) 1e9+7;
template<class X,class Y> bool minimize(X &a,Y b){ if (a>b) {a=b; return true;} return false;}
template<class X,class Y> bool maximize(X &a,Y b){ if (a<b) {a=b; return true;} return false;}
void setup(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
if (fopen(FNAME".inp","r")){
freopen(FNAME".inp","r",stdin);
freopen(FNAME".out","w",stdout);
}
}
long long a,b,c;
void add(long long x,long long y){
while (x){
long long t = a/x;
a-= x*t;
b-= y*t;
swap(a,x);
swap(b,y);
}
c = __gcd(c,y);
if (c) b%=c;
}
int n;
long long p,q;
vector<pair<long long,long long>> v;
void init(){
cin>>n>>p>>q;
for (int i=1;i<n;i++){
long long x,y;
cin>>x>>y;
add(x-p,y-q);
}
}
void sol(){
cout<< (a*c==0 ? -1 : llabs(a*c));
}
int main(){
setup();
init();
sol();
}
Compilation message (stderr)
# | 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... |