Source code for submission s679

Fl.java

  1.  
  2. import java.util.HashSet;
  3. import java.util.Scanner;
  4.  
  5. /*
  6.  * To change this template, choose Tools | Templates
  7.  * and open the template in the editor.
  8.  */
  9.  
  10. /**
  11.  *
  12.  * @author kajanek6
  13.  */
  14. public class Fl {
  15.  
  16.  
  17. public static void main(String[] args) {
  18. HashSet<Double> mnozina=new HashSet<Double>();
  19. double n=0;
  20. int counter=0;
  21. double y=0;
  22. Scanner input = new Scanner(System.in);
  23. while (input.hasNextLine()) {
  24. counter=0;
  25. String temp = input.nextLine();
  26. n=Double.parseDouble(temp.substring(2));
  27. for(double i=1;i<10000;i++)
  28. {
  29. if((i-n)>0){
  30. double vysl = n*i/(i-n);
  31. //System.out.println(Math.abs(vysl-Math.round(vysl)));
  32. if(vysl>0 && Math.abs(vysl-Math.round(vysl))<0.0001)
  33. {
  34. if(!mnozina.contains(i)){
  35. counter++;
  36. mnozina.add(i);
  37. mnozina.add((double)Math.round(vysl));
  38. }
  39.  
  40.  
  41. }
  42. }
  43. }
  44. System.out.printf("%d\n",counter);
  45. }
  46. }
  47.  
  48. public class pair{
  49. public int prvy;
  50. public int druhy;
  51.  
  52. public pair(int a,int b){
  53. prvy=a;
  54. druhy=b;
  55. }
  56. }
  57. }
  58.