結果
問題 | No.1532 Different Products |
ユーザー | kusomushi |
提出日時 | 2021-06-05 20:57:20 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,159 ms / 4,000 ms |
コード長 | 3,934 bytes |
コンパイル時間 | 3,761 ms |
コンパイル使用メモリ | 91,208 KB |
実行使用メモリ | 70,300 KB |
最終ジャッジ日時 | 2024-11-21 19:52:17 |
合計ジャッジ時間 | 45,337 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 59 ms
44,344 KB |
testcase_01 | AC | 353 ms
57,616 KB |
testcase_02 | AC | 60 ms
37,312 KB |
testcase_03 | AC | 57 ms
37,552 KB |
testcase_04 | AC | 58 ms
37,480 KB |
testcase_05 | AC | 59 ms
37,516 KB |
testcase_06 | AC | 74 ms
38,764 KB |
testcase_07 | AC | 84 ms
38,732 KB |
testcase_08 | AC | 95 ms
39,520 KB |
testcase_09 | AC | 202 ms
46,952 KB |
testcase_10 | AC | 357 ms
54,992 KB |
testcase_11 | AC | 370 ms
54,340 KB |
testcase_12 | AC | 732 ms
60,996 KB |
testcase_13 | AC | 473 ms
57,512 KB |
testcase_14 | AC | 947 ms
66,196 KB |
testcase_15 | AC | 108 ms
40,724 KB |
testcase_16 | AC | 357 ms
52,668 KB |
testcase_17 | AC | 317 ms
52,936 KB |
testcase_18 | AC | 289 ms
52,524 KB |
testcase_19 | AC | 663 ms
60,112 KB |
testcase_20 | AC | 999 ms
63,924 KB |
testcase_21 | AC | 441 ms
56,544 KB |
testcase_22 | AC | 488 ms
56,900 KB |
testcase_23 | AC | 290 ms
53,784 KB |
testcase_24 | AC | 813 ms
63,620 KB |
testcase_25 | AC | 624 ms
57,356 KB |
testcase_26 | AC | 220 ms
45,884 KB |
testcase_27 | AC | 537 ms
56,780 KB |
testcase_28 | AC | 422 ms
55,084 KB |
testcase_29 | AC | 419 ms
54,532 KB |
testcase_30 | AC | 675 ms
57,780 KB |
testcase_31 | AC | 687 ms
58,360 KB |
testcase_32 | AC | 723 ms
60,624 KB |
testcase_33 | AC | 591 ms
57,036 KB |
testcase_34 | AC | 777 ms
61,524 KB |
testcase_35 | AC | 686 ms
59,484 KB |
testcase_36 | AC | 873 ms
63,100 KB |
testcase_37 | AC | 335 ms
49,540 KB |
testcase_38 | AC | 920 ms
65,000 KB |
testcase_39 | AC | 709 ms
60,072 KB |
testcase_40 | AC | 739 ms
59,244 KB |
testcase_41 | AC | 975 ms
63,900 KB |
testcase_42 | AC | 857 ms
60,772 KB |
testcase_43 | AC | 991 ms
63,460 KB |
testcase_44 | AC | 1,142 ms
67,484 KB |
testcase_45 | AC | 1,027 ms
64,008 KB |
testcase_46 | AC | 956 ms
63,244 KB |
testcase_47 | AC | 979 ms
66,204 KB |
testcase_48 | AC | 973 ms
63,888 KB |
testcase_49 | AC | 1,046 ms
65,452 KB |
testcase_50 | AC | 920 ms
64,268 KB |
testcase_51 | AC | 930 ms
64,160 KB |
testcase_52 | AC | 1,080 ms
66,880 KB |
testcase_53 | AC | 985 ms
66,104 KB |
testcase_54 | AC | 992 ms
65,540 KB |
testcase_55 | AC | 1,121 ms
65,880 KB |
testcase_56 | AC | 920 ms
63,188 KB |
testcase_57 | AC | 1,066 ms
70,300 KB |
testcase_58 | AC | 981 ms
65,832 KB |
testcase_59 | AC | 893 ms
63,152 KB |
testcase_60 | AC | 1,159 ms
68,304 KB |
testcase_61 | AC | 60 ms
37,668 KB |
testcase_62 | AC | 55 ms
37,196 KB |
testcase_63 | AC | 972 ms
65,328 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { static int N; static long K; public static void main(String[] args) { FastScanner sc = new FastScanner(System.in); N = sc.nextInt(); K = sc.nextLong(); System.out.println(solve()); } static long solve() { // 人のを見て実装した // 200 1000000000 のケースでもentryの数は33989にしかならない var dp = new HashMap<Long, Long>(); dp.put(K, 1L); for (int i = N; i >= 1; i--) { var prev = new HashMap<>(dp); for (var entry : prev.entrySet()) { var x = entry.getKey(); var v = entry.getValue(); dp.merge(x / i, v, Long::sum); } } // debug(dp.size()); long ans = -1; for (var entry : dp.entrySet()) { var x = entry.getKey(); var v = entry.getValue(); if( x != 0 ) { ans += v; } } return ans; } @SuppressWarnings("unused") static class FastScanner { private BufferedReader reader; private StringTokenizer tokenizer; FastScanner(InputStream in) { reader = new BufferedReader(new InputStreamReader(in)); tokenizer = null; } String next() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } String nextLine() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken("\n"); } long nextLong() { return Long.parseLong(next()); } int nextInt() { return Integer.parseInt(next()); } int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } int[] nextIntArray(int n, int delta) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt() + delta; return a; } long[] nextLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } } static void writeLines(int[] as) { PrintWriter pw = new PrintWriter(System.out); for (int a : as) pw.println(a); pw.flush(); } static void writeLines(long[] as) { PrintWriter pw = new PrintWriter(System.out); for (long a : as) pw.println(a); pw.flush(); } static void writeSingleLine(int[] as) { PrintWriter pw = new PrintWriter(System.out); for (int i = 0; i < as.length; i++) { if (i != 0) pw.print(" "); pw.print(as[i]); } pw.println(); pw.flush(); } static void debug(Object... args) { StringJoiner j = new StringJoiner(" "); for (Object arg : args) { if (arg == null) j.add("null"); else if (arg instanceof int[]) j.add(Arrays.toString((int[]) arg)); else if (arg instanceof long[]) j.add(Arrays.toString((long[]) arg)); else if (arg instanceof double[]) j.add(Arrays.toString((double[]) arg)); else if (arg instanceof Object[]) j.add(Arrays.toString((Object[]) arg)); else j.add(arg.toString()); } System.err.println(j.toString()); } }