fork(1) download
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. //import java.util.Arrays;
  5. //import java.util.Arrays;
  6. //import java.util.HashMap;
  7. import java.util.HashSet;
  8. import java.util.StringTokenizer;
  9.  
  10.  
  11. class LINES {
  12.  
  13. public static void main(String[] args) throws NumberFormatException, IOException {
  14. // TODO Auto-generated method stub
  15. StringBuilder sb=new StringBuilder();
  16. while(true){
  17. int N=Integer.parseInt(br.readLine());
  18. if(N==0)break;
  19. int co[][]=new int[N][2];
  20. for(int i=0;i<N;i++){
  21. StringTokenizer st=new StringTokenizer(br.readLine());
  22. co[i][0]=Integer.parseInt(st.nextToken());
  23. co[i][1]=Integer.parseInt(st.nextToken());
  24. }
  25.  
  26. //int k=0;
  27. HashSet<Double> hs=new HashSet<Double>();
  28. for(int i=0;i<N;i++){
  29. for(int j=i+1;j<N;j++){
  30. double ax=(co[j][1]-co[i][1])*1.0/(co[j][0]-co[i][0]);
  31. //System.out.println(ax);
  32. hs.add(ax);
  33. }
  34. }
  35. sb.append(hs.size()+"\n");
  36. }
  37. System.out.println(sb);
  38. }
  39.  
  40. }
  41.  
Success #stdin #stdout 0.07s 380224KB
stdin
4
-1 1
-2 0
0 0
1 1
0
stdout
4