Advertisement
999ms

Untitled

May 26th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4.   int n;
  5.   cin>>n;
  6.   vector<pair<int,int> > v(n);
  7.   for(int i=0; i<n; i++) {
  8.     cin>>v[i].first>>v[i].second;
  9.   }
  10.   sort(v.begin(),v.end());
  11.   int a = v[1].first - v[0].first;
  12.   int b = v[1].second - v[0].second;
  13.   int g = __gcd(abs(a), abs(b));
  14.   a /= g;
  15.   b /= g;
  16.   bool answer = true;
  17.   for(int i = 1; i < n - 1; i++) {
  18.     int dx = v[i + 1].first - v[i].first;
  19.     int dy = v[i + 1].second - v[i].second;
  20.     g = __gcd(abs(dx),abs(dy));
  21.     dx /= g;
  22.     dy /= g;
  23.     answer &= (dx == a) && (dy == b);
  24.   }
  25.   cout<<(answer ? "Yes" : "No");
  26.   return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement