Source code for submission s670

Fl.java

  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. //package fs;
  6.  
  7. import java.io.BufferedReader;
  8. import java.io.IOException;
  9. import java.io.InputStreamReader;
  10.  
  11.  
  12. /**
  13.  *
  14.  * @author cteam039
  15.  */
  16. public class Fl {
  17.  
  18. public static void main(String... args) {
  19.  
  20.  
  21. try {
  22. String line = reader.readLine();
  23.  
  24. while (line != null) {
  25. int n = 1;
  26. try{
  27. n = Integer.parseInt(line.split("/")[1]);
  28. return;
  29. }
  30. // System.out.println("n: " + n);
  31. int counter = 0;
  32. for (int i = n + 1; i <= n * 2; i++) {
  33. double x = (n * i) / ((double) (i - n));
  34. int iXd = (int) x;
  35. int iXu = (int) (x) + 1;
  36. if ((Math.abs(x - iXd) < 1.0 / (n * n * n * n)) || (Math.abs(x - iXu)) < 1.0 / (n * n * n * n)) {
  37. counter++;
  38. }
  39. }
  40. System.out.println(counter);
  41. line = reader.readLine();
  42. }
  43. } catch (IOException ex) {
  44. }
  45. }
  46. }
  47.