Go to diff to previous submission
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.regex.Pattern; public class fl { int[] predvypocet= new int[10001]; for (long n = 0; n < 10001; n++) { int count = 0; Set<Integer> s=new HashSet<Integer>(); for (long x = n + 1; x < 20001; x++) { if (x - n != 0) { int ymod = (int) ((n * x) % (x - n)); if (ymod == 0) { int y = (int) ((n * x) / (x - n)); if (y != 0) { if (!s.contains(y)) { s.add((int) x); s.add(y); count++; // System.out // .println("n " + n + " x: " + x + " y" + y); } } } } } predvypocet[(int) n]=count; } Pattern p = Pattern.compile("/"); String line; while ((line = buf.readLine()) != null) { } } }
--- c5.s691.cteam096.fl.java.0.fl.java +++ c5.s720.cteam096.fl.java.0.fl.java @@ -13,49 +12,8 @@ public static void main(String[] args) throws IOException { - - - - -// int[] res = new int[10002]; -// int[] res2 = new int[10002]; -// long o = 10000000; -// for(long x=1; x<100000; x++){ -// for(long y=x; y<o; y+=x){ -// if(x*y % (x+y)==0){ -// int n = ((int)(x*y/(x+y))); -// if(n<res.length) -// res[n]++; -// if(n==5000) -// System.out.println(x + " " + y + " " + x*y/(x+y)); -// } -// } -// } -// System.out.println(Arraresultys.toString(res)); -// for(int n=5000; n<5001; n++){ -// for (int i = 1; i <= n; i++) { -// if(n % i == 0){ -// res2[n]++; -// System.out.println(i); -// } -// } -// } -// System.out.println(Arrays.toString(res2)); -// for(int i=0; i< 1000; i++){ -// if (res[i] != res2[i]){ -// System.out.println(i); -// break; -// } -// } -// System.out.println(res[5000]); -// System.out.println(res2[5000]); - - BufferedReader buf = new BufferedReader(new InputStreamReader(System.in)); - Pattern p = Pattern.compile("/"); - String line; - while ((line = buf.readLine()) != null) { - String[] s = p.split(line); - int n = Integer.parseInt(s[1]); + int[] predvypocet= new int[10001]; + for (long n = 0; n < 10001; n++) { int count = 0; - Set<Integer> set=new HashSet<Integer>(); + Set<Integer> s=new HashSet<Integer>(); for (long x = n + 1; x < 20001; x++) { if (x - n != 0) { @@ -64,7 +22,7 @@ int y = (int) ((n * x) / (x - n)); if (y != 0) { - if (!set.contains(y)) { - set.add((int) x); - set.add(y); + if (!s.contains(y)) { + s.add((int) x); + s.add(y); count++; // System.out @@ -77,5 +35,16 @@ } } - System.out.println(count); + predvypocet[(int) n]=count; + + } + + BufferedReader buf = new BufferedReader( + new InputStreamReader(System.in)); + Pattern p = Pattern.compile("/"); + String line; + while ((line = buf.readLine()) != null) { + String[] s = p.split(line); + int n = Integer.parseInt(s[1]); + System.out.println(predvypocet[n]); } }