Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main() {
- int n;
- cin>>n;
- vector<pair<int,int> > v(n);
- for(int i=0; i<n; i++) {
- cin>>v[i].first>>v[i].second;
- }
- sort(v.begin(),v.end());
- int a = v[1].first - v[0].first;
- int b = v[1].second - v[0].second;
- int g = __gcd(abs(a), abs(b));
- a /= g;
- b /= g;
- bool answer = true;
- for(int i = 1; i < n - 1; i++) {
- int dx = v[i + 1].first - v[i].first;
- int dy = v[i + 1].second - v[i].second;
- g = __gcd(abs(dx),abs(dy));
- dx /= g;
- dy /= g;
- answer &= (dx == a) && (dy == b);
- }
- cout<<(answer ? "Yes" : "No");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement