Source code for submission s691

fl.java

  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.ArrayList;
  5. import java.util.Arrays;
  6. import java.util.HashSet;
  7. import java.util.List;
  8. import java.util.Set;
  9. import java.util.regex.Pattern;
  10.  
  11.  
  12. public class fl {
  13.  
  14. public static void main(String[] args) throws IOException {
  15.  
  16.  
  17.  
  18.  
  19. // int[] res = new int[10002];
  20. // int[] res2 = new int[10002];
  21. // long o = 10000000;
  22. // for(long x=1; x<100000; x++){
  23. // for(long y=x; y<o; y+=x){
  24. // if(x*y % (x+y)==0){
  25. // int n = ((int)(x*y/(x+y)));
  26. // if(n<res.length)
  27. // res[n]++;
  28. // if(n==5000)
  29. // System.out.println(x + " " + y + " " + x*y/(x+y));
  30. // }
  31. // }
  32. // }
  33. // System.out.println(Arraresultys.toString(res));
  34. // for(int n=5000; n<5001; n++){
  35. // for (int i = 1; i <= n; i++) {
  36. // if(n % i == 0){
  37. // res2[n]++;
  38. // System.out.println(i);
  39. // }
  40. // }
  41. // }
  42. // System.out.println(Arrays.toString(res2));
  43. // for(int i=0; i< 1000; i++){
  44. // if (res[i] != res2[i]){
  45. // System.out.println(i);
  46. // break;
  47. // }
  48. // }
  49. // System.out.println(res[5000]);
  50. // System.out.println(res2[5000]);
  51.  
  52. Pattern p = Pattern.compile("/");
  53. String line;
  54. while ((line = buf.readLine()) != null) {
  55. String[] s = p.split(line);
  56. int n = Integer.parseInt(s[1]);
  57. int count = 0;
  58. Set<Integer> set=new HashSet<Integer>();
  59. for (long x = n + 1; x < 20001; x++) {
  60. if (x - n != 0) {
  61. int ymod = (int) ((n * x) % (x - n));
  62. if (ymod == 0) {
  63. int y = (int) ((n * x) / (x - n));
  64. if (y != 0) {
  65. if (!set.contains(y)) {
  66. set.add((int) x);
  67. set.add(y);
  68. count++;
  69. // System.out
  70. // .println("n " + n + " x: " + x + " y" + y);
  71. }
  72.  
  73. }
  74. }
  75.  
  76. }
  77. }
  78. System.out.println(count);
  79. }
  80. }
  81.  
  82. }
  83.