Source code for submission s746

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

Diff to submission s732

Fl.java

--- c5.s732.cteam087.fl.java.0.Fl.java
+++ c5.s746.cteam087.fl.java.0.Fl.java
@@ -24,5 +24,7 @@
             counter=0;
             String temp = input.nextLine();
-            if(temp.length()<2){break;}
+            if(temp.length()==0){
+                continue;
+            }
             n=Integer.parseInt(temp.substring(2));
             for(int i=1;i<=10000;i++)