Source code for submission s618

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.  
  17. int n = Integer.parseInt(sc.next().substring(2));
  18. sc.nextLine();
  19.  
  20. int x = n + 1;
  21.  
  22. double y = (n*x)/ (double) (x-n);
  23.  
  24. int sum = 0;
  25.  
  26. List<Integer> list = new ArrayList<Integer>();
  27.  
  28.  
  29. for (; ; x++) { // y < n +1
  30. y = (n*x)/ (double) (x-n);
  31.  
  32. if (y < n+1) break;
  33.  
  34. if ((int) y - y == 0) {
  35. if (list.contains((int) y)) break;
  36.  
  37. sum++;
  38. list.add(x);
  39. }
  40. }
  41.  
  42. System.out.println(sum);
  43.  
  44.  
  45. }
  46. }
  47.  
  48. }
  49.  

Diff to submission s611

Fl.java

--- c5.s611.cteam054.fl.java.0.Fl.java
+++ c5.s618.cteam054.fl.java.0.Fl.java
@@ -16,13 +16,5 @@
                 
                         int n = Integer.parseInt(sc.next().substring(2));                       
-                        sc.nextLine();
-                
-                        
-                        if (n == 1) {
-                                System.out.println("1");
-                                continue;
-                        }
-                        
-                        
+                        sc.nextLine();          
                         
                         int x = n + 1;
@@ -38,5 +30,5 @@
                                 y = (n*x)/ (double) (x-n);
                                         
-                                if (y <= n+1) break;
+                                if (y < n+1) break;
                                 
                                 if ((int) y - y == 0) {