Source code for submission s799

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.  
  28. int sum = 0;
  29.  
  30. //List<Integer> list = new ArrayList<Integer>();
  31.  
  32.  
  33. for (; x <= 2 * n ; x++) { // y < n +1
  34. y = (n*x)/ (double) (x-n);
  35.  
  36. if (y < n+1) break;
  37.  
  38. if ((int) y - y == 0) {
  39. //if (list.contains((int) y)) break;
  40.  
  41. sum++;
  42. //list.add(x);
  43. }
  44. }
  45.  
  46. System.out.println(sum);
  47.  
  48.  
  49. }
  50. }
  51.  
  52. }
  53.  

Diff to submission s747

Fl.java

--- c5.s747.cteam054.fl.java.0.Fl.java
+++ c5.s799.cteam054.fl.java.0.Fl.java
@@ -25,23 +25,20 @@
                         double y = (n*x)/ (double) (x-n);
                         
-                        double prvni_y = y;
-                        
+                                                
                         int sum = 0;                                    
                         
-                        List<Integer> list = new ArrayList<Integer>();  
+                        //List<Integer> list = new ArrayList<Integer>();        
                         
                         
-                        for (;  ; x++) {                        // y < n +1 
+                        for (; x <= 2 * n ; x++) {                      // y < n +1 
                                 y = (n*x)/ (double) (x-n);
                                         
-                                if (y < n+1) break;
-                                if (x > prvni_y) break;
-                                
+                                if (y < n+1) break;                             
                                 
                                 if ((int) y - y == 0) {
-                                        if (list.contains((int) y)) break;
+                                        //if (list.contains((int) y)) break;
                                         
                                         sum++;
-                                        list.add(x);
+                                        //list.add(x);
                                 }
                         }