Source code for submission s572

Fl.java

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