#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
pair<long long,long long> P[MAXN];
long long X[MAXN],Y[MAXN];
bool comp(pair<long long,long long> a,pair<long long,long long> b) { return (a.second==0)>(b.second==0); }
bool comp2(pair<long long,long long> a,pair<long long,long long> b) { return (a.first==0)>(b.first==0); }
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n,g=0,h=0;
cin>>n;
if(n<=2) return cout<<-1,0;
for(int i=1;i<=n;i++) cin>>P[i].first>>P[i].second;
sort(P+1,P+n+1);
for(int i=1;i<n;i++) P[i].first-=P[i+1].first,P[i].second-=P[i+1].second,h=__gcd(h,P[i].second);
sort(P+1,P+n,comp);
if(P[n-1].second==0) h=__gcd(h,P[n-1].first);
for(int i=1;i<n-1;i++) if(P[i].second==0) h=__gcd(h,P[i].first);
else h=__gcd(h,(P[i].first*P[i+1].second-P[i+1].first*P[i].second)/__gcd(P[i].second,P[i+1].second));
sort(P+1,P+n,comp2);
if(P[n-1].first==0) g=__gcd(g,P[n-1].second);
for(int i=1;i<n-1;i++) if(P[i].first==0) g=__gcd(g,P[i].second);
else g=__gcd(g,(P[i].second*P[i+1].first-P[i+1].second*P[i].first)/__gcd(P[i].first,P[i+1].first));
if(!g||!h) return cout<<-1,0;
cout<<abs(g*h);
}
# | 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... |