Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define forn(i, n) for(int i = 0; i < (int)(n); ++i)
  4.  
  5. using namespace std;
  6.  
  7. struct pt
  8. {
  9. int x, y;
  10. };
  11.  
  12. pt operator-(const pt &a, const pt &b)
  13. {
  14. pt res;
  15. res.x = b.x - a.x;
  16. res.y = b.y - a.y;
  17. return res;
  18. }
  19.  
  20. int64_t vec_mult(const pt &a, const pt &b)
  21. {
  22. return (int64_t)(a.x) * b.y - (int64_t)(a.y) * b.x;
  23. }
  24.  
  25. int64_t scal_mult(const pt &a, const pt &b)
  26. {
  27. return (int64_t)(a.x) * b.x + (int64_t)(a.y) * b.y;
  28. }
  29.  
  30. int main()
  31. {
  32. int n;
  33. cin >> n;
  34. vector<pt> p(n);
  35. int ans = 0;
  36. forn (i, n) cin >> p[i].x >> p[i].y;
  37. sort(p.begin(), p.end());
  38. for (int i = 0; i < n - 2; ++i) // a
  39. {
  40. for (int j = i + 1; j < n - 1; ++j) // b
  41. {
  42. for (int m = j + 1; m < n; ++m) // c
  43. {
  44. if (scal_mult(p[m] - p[j], p[i] - p[m]) == 0) ++ans;
  45. }
  46. }
  47. }
  48. cout << ans << "\n";
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement