Source code for submission s782

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. mnozina.clear();
  25. counter=0;
  26. String temp = input.nextLine();
  27. if(temp.length()>1)
  28. { n=Integer.parseInt(temp.substring(2));
  29. for(int i=1;i<=20000;i++)
  30. {
  31. if((i-n)>0){
  32. int vysl = (n*i)/(i-n);
  33. int zvysok=(n*i)%(i-n);
  34. if(vysl>0 && zvysok==0)
  35. {
  36. if(!mnozina.contains(i)){
  37. counter++;
  38. mnozina.add(i);
  39. mnozina.add(vysl);
  40. }
  41.  
  42.  
  43. }
  44. }
  45. }
  46. System.out.printf("%d\n",counter);
  47. }}
  48. }
  49.  
  50. public class pair{
  51. public int prvy;
  52. public int druhy;
  53.  
  54. public pair(int a,int b){
  55. prvy=a;
  56. druhy=b;
  57. }
  58. }
  59. }
  60.  

Diff to submission s771

Fl.java

--- c5.s771.cteam087.fl.java.0.Fl.java
+++ c5.s782.cteam087.fl.java.0.Fl.java
@@ -25,9 +25,7 @@
             counter=0;
             String temp = input.nextLine();
-            if(temp.length()==0){
-                continue;
-            }
-            n=Integer.parseInt(temp.substring(2));
-            for(int i=1;i<=100000;i++)
+            if(temp.length()>1)
+            { n=Integer.parseInt(temp.substring(2));
+            for(int i=1;i<=20000;i++)
             {
                 if((i-n)>0){
@@ -47,5 +45,5 @@
             }
             System.out.printf("%d\n",counter);
-    }
+    }}
     }