fork download
  1. #include <cstdio>
  2. #include <algorithm>
  3. #include <map>
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8. int N,x[200],y[200];
  9.  
  10. while(true){
  11. scanf("%d",&N);
  12. if(N==0) break;
  13.  
  14. for(int i = 0;i<N;++i)
  15. scanf("%d %d",&x[i],&y[i]);
  16.  
  17. map< pair<int, int> , int > M;
  18.  
  19. for(int i = 0;i<N;++i){
  20. for(int j = i+1;j<N;++j){
  21. int dx = x[i]-x[j],dy = y[i]-y[j];
  22. int g = __gcd(dx,dy);
  23.  
  24. dx /= g; dy /= g;
  25.  
  26. if(dx<0){
  27. dx = -dx;
  28. dy = -dy;
  29. }
  30.  
  31. M[make_pair(dx,dy)]++;
  32. }
  33. }
  34.  
  35. printf("%d\n",(int)M.size());
  36. }
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0s 3476KB
stdin
4
-1 1
-2 0
0 0
1 1
0
stdout
4