Source code for submission s521

Fl.java

  1. /*
  2.  * CTU Open 2013
  3.  * HES
  4.  */
  5. package template;
  6.  
  7. import java.io.BufferedReader;
  8. import java.io.InputStreamReader;
  9. import java.util.StringTokenizer;
  10.  
  11. /**
  12.  *
  13.  * @author cteam007
  14.  */
  15. public class Fl {
  16.  
  17.  
  18. void useLine(String s) {
  19. st = new StringTokenizer(s);
  20. }
  21.  
  22. String nextToken() throws Exception {
  23. while (!st.hasMoreTokens()) {
  24. st = new StringTokenizer(input.readLine());
  25. }
  26. return st.nextToken();
  27. }
  28.  
  29. int nextInt() throws Exception {
  30. return Integer.parseInt(nextToken());
  31. }
  32.  
  33. /**
  34.   * @param args the command line arguments
  35.   */
  36. public static void main(String[] args) throws Exception {
  37. Fl instance = new Fl();
  38. while (instance.run()) {
  39. }
  40. }
  41.  
  42. boolean run() throws Exception {
  43. String in = input.readLine();
  44. if (in == null) {
  45. return false;
  46. }
  47.  
  48. useLine(in);
  49.  
  50.  
  51. String fraction = nextToken();
  52.  
  53. int n = Integer.parseInt(fraction.substring(2, fraction.length()));
  54. int c = 1;
  55.  
  56. for(int i = n+1; i < 2*n; i++){
  57. if((n*i)%(i-n) == 0 ){
  58. c++;
  59. }
  60. }
  61.  
  62. System.out.println(c);
  63.  
  64. return true;
  65. }
  66. }
  67.