Source code for submission s715

Go to diff to previous submission

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<Integer> mnozina=new HashSet<Integer>();
  19. int n=0;
  20. int counter=0;
  21. int y=0;
  22. Scanner input = new Scanner(System.in);
  23. while (input.hasNextLine()) {
  24. counter=0;
  25. String temp = input.nextLine();
  26. n=Integer.parseInt(temp.substring(2));
  27. for(int i=1;i<=10000;i++)
  28. {
  29. if((i-n)>0){
  30. int vysl = (n*i)/(i-n);
  31. int zvysok=(n*i)%(i-n);
  32. if(vysl>0 && zvysok==0)
  33. {
  34. if(!mnozina.contains(i)){
  35. counter++;
  36. mnozina.add(i);
  37. mnozina.add(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.  

Diff to submission s679

Fl.java

--- c5.s679.cteam087.fl.java.0.Fl.java
+++ c5.s715.cteam087.fl.java.0.Fl.java
@@ -16,24 +16,24 @@
     
     public static void main(String[] args) {
-        HashSet<Double> mnozina=new HashSet<Double>();
-        double n=0;
+        HashSet<Integer> mnozina=new HashSet<Integer>();
+        int n=0;
         int counter=0;
-        double y=0;
+        int y=0;
         Scanner input = new Scanner(System.in);
         while (input.hasNextLine()) {
             counter=0;
             String temp = input.nextLine();
-            n=Double.parseDouble(temp.substring(2));
-            for(double i=1;i<10000;i++)
+            n=Integer.parseInt(temp.substring(2));
+            for(int i=1;i<=10000;i++)
             {
                 if((i-n)>0){
-                    double vysl = n*i/(i-n);
-                    //System.out.println(Math.abs(vysl-Math.round(vysl)));
-                    if(vysl>0 && Math.abs(vysl-Math.round(vysl))<0.0001)
+                    int vysl = (n*i)/(i-n);
+                    int zvysok=(n*i)%(i-n);
+                    if(vysl>0 && zvysok==0)
                     {
                         if(!mnozina.contains(i)){
                             counter++;
                             mnozina.add(i);
-                             mnozina.add((double)Math.round(vysl));
+                             mnozina.add(vysl);
                         }