Advertisement
limimage

TASK A

May 26th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. using ll = long long;
  7. using pii = pair<int, int>;
  8.  
  9. vector<pii> cords;
  10.  
  11. pii getK(pair<int,int> a, pair<int,int> b) {
  12. a.first -= b.first;
  13. a.second -= b.second;
  14. int g = __gcd(abs(a.first), abs(a.first));
  15. if (g!=0)
  16. {
  17. a.first /= g;
  18. a.second /= g;
  19. }
  20. if (a.first==0)
  21. a.second = 1;
  22. if (a.second==0)
  23. a.first = 1;
  24. return { a.first, a.second };
  25. }
  26.  
  27. int main() {
  28. ios_base::sync_with_stdio(false);
  29. cin.tie(nullptr);
  30.  
  31. int n;
  32. cin >> n;
  33. pii p1, p2;
  34. cin >> p1.first >> p1.second >> p2.first >> p2.second;
  35. pii k = getK(p1, p2);
  36. int check = 0;
  37. pii el;
  38. for (int i = 0; i < n - 2; i++) {
  39. cin >> el.first >> el.second;
  40. if (k!=getK(p1, el)) {
  41. check = 1;
  42. break;
  43. }
  44. }
  45. check ? cout << "no" : cout << "yes";
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement