Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11. using namespace std;
  12.  
  13.  
  14.  
  15. int gcd(int a, int b) {
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23. if (a==0) return b;
  24.  
  25.  
  26.  
  27. if (b==0) return a;
  28.  
  29.  
  30.  
  31. return gcd(max(a,b)%min(a,b),min(a,b));
  32.  
  33.  
  34.  
  35. }
  36.  
  37.  
  38.  
  39. signed main() {
  40.  
  41.  
  42.  
  43. int a;
  44.  
  45.  
  46.  
  47. cin>>a;
  48.  
  49.  
  50.  
  51. int x[a],y[a];
  52.  
  53.  
  54.  
  55. for (int i=0;i<a;i++) {
  56.  
  57.  
  58.  
  59. cin>>x[i]>>y[i];
  60.  
  61.  
  62.  
  63. }
  64.  
  65.  
  66.  
  67. int ans=0;
  68.  
  69.  
  70.  
  71. for (int i=0;i<a;i++) {
  72.  
  73.  
  74.  
  75. map <pair<int,int>,int> used;
  76.  
  77.  
  78.  
  79. for (int j=0;j<a;j++) if (j!=i) { int p=gcd(abs(x[j]-x[i]),abs(y[j]-y[i]));
  80.  
  81. used[{(x[j]-x[i])/p,(y[j]-y[i])/p}]++; }
  82.  
  83.  
  84.  
  85. for (int j=0;j<a;j++) {
  86.  
  87.  
  88.  
  89. if (j!=i) {
  90.  
  91. int p=gcd(abs(x[j]-x[i]),abs(y[j]-y[i]));
  92.  
  93. if (x[j]!=x[i] && y[j]!=y[i]) { ans+=used[{(y[i]-y[j])/p,(x[j]-x[i])/p}];
  94.  
  95.  
  96.  
  97. }
  98.  
  99.  
  100.  
  101. else if (x[j]==x[i]) ans+=used[{1,0}]+used[{-1,0}];
  102.  
  103.  
  104.  
  105. }
  106.  
  107.  
  108.  
  109. }
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119. }
  120.  
  121.  
  122.  
  123. cout<<ans;
  124.  
  125.  
  126.  
  127. return 0;
  128.  
  129.  
  130.  
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement