Source code for submission s747

Go to diff to previous submission

Fl.java

  1.  
  2. import java.io.*;
  3. import java.util.*;
  4.  
  5.  
  6. public class Fl {
  7.  
  8. public static void main(String[] args) throws FileNotFoundException {
  9.  
  10. Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
  11. //Scanner sc = new Scanner(new BufferedReader(new FileReader(new File("in.txt"))));
  12.  
  13. //int i = 1;
  14.  
  15. while (sc.hasNextLine()) {
  16. //while(i < 10000) {
  17. int n = Integer.parseInt(sc.next().substring(2));
  18. sc.nextLine();
  19.  
  20. //int n = i++;
  21. //System.out.print(n + " : ");
  22.  
  23. int x = n + 1;
  24.  
  25. double y = (n*x)/ (double) (x-n);
  26.  
  27. double prvni_y = y;
  28.  
  29. int sum = 0;
  30.  
  31. List<Integer> list = new ArrayList<Integer>();
  32.  
  33.  
  34. for (; ; x++) { // y < n +1
  35. y = (n*x)/ (double) (x-n);
  36.  
  37. if (y < n+1) break;
  38. if (x > prvni_y) break;
  39.  
  40.  
  41. if ((int) y - y == 0) {
  42. if (list.contains((int) y)) break;
  43.  
  44. sum++;
  45. list.add(x);
  46. }
  47. }
  48.  
  49. System.out.println(sum);
  50.  
  51.  
  52. }
  53. }
  54.  
  55. }
  56.  

Diff to submission s666

Fl.java

--- c5.s666.cteam054.fl.java.0.Fl.java
+++ c5.s747.cteam054.fl.java.0.Fl.java
@@ -25,4 +25,6 @@
                         double y = (n*x)/ (double) (x-n);
                         
+                        double prvni_y = y;
+                        
                         int sum = 0;                                    
                         
@@ -30,8 +32,10 @@
                         
                         
-                        for (; x < 20 ; x++) {                  // y < n +1 
+                        for (;  ; x++) {                        // y < n +1 
                                 y = (n*x)/ (double) (x-n);
                                         
                                 if (y < n+1) break;
+                                if (x > prvni_y) break;
+                                
                                 
                                 if ((int) y - y == 0) {