Source code for submission s666

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

Diff to submission s665

Fl.java