結果
問題 | No.1532 Different Products |
ユーザー | kusomushi |
提出日時 | 2021-06-05 20:57:20 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,018 ms / 4,000 ms |
コード長 | 3,934 bytes |
コンパイル時間 | 2,510 ms |
コンパイル使用メモリ | 82,556 KB |
実行使用メモリ | 80,192 KB |
最終ジャッジ日時 | 2024-05-01 15:01:35 |
合計ジャッジ時間 | 40,193 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 58 ms
50,660 KB |
testcase_01 | AC | 353 ms
65,128 KB |
testcase_02 | AC | 61 ms
50,144 KB |
testcase_03 | AC | 58 ms
50,768 KB |
testcase_04 | AC | 58 ms
50,260 KB |
testcase_05 | AC | 62 ms
50,700 KB |
testcase_06 | AC | 64 ms
50,988 KB |
testcase_07 | AC | 86 ms
51,708 KB |
testcase_08 | AC | 91 ms
51,852 KB |
testcase_09 | AC | 188 ms
57,060 KB |
testcase_10 | AC | 372 ms
66,216 KB |
testcase_11 | AC | 349 ms
65,324 KB |
testcase_12 | AC | 635 ms
70,264 KB |
testcase_13 | AC | 402 ms
66,936 KB |
testcase_14 | AC | 804 ms
76,264 KB |
testcase_15 | AC | 102 ms
53,832 KB |
testcase_16 | AC | 321 ms
63,324 KB |
testcase_17 | AC | 333 ms
65,264 KB |
testcase_18 | AC | 262 ms
63,316 KB |
testcase_19 | AC | 609 ms
70,356 KB |
testcase_20 | AC | 874 ms
73,952 KB |
testcase_21 | AC | 399 ms
66,740 KB |
testcase_22 | AC | 456 ms
67,052 KB |
testcase_23 | AC | 313 ms
65,480 KB |
testcase_24 | AC | 741 ms
73,708 KB |
testcase_25 | AC | 507 ms
64,952 KB |
testcase_26 | AC | 196 ms
57,280 KB |
testcase_27 | AC | 472 ms
66,676 KB |
testcase_28 | AC | 375 ms
64,696 KB |
testcase_29 | AC | 386 ms
65,112 KB |
testcase_30 | AC | 649 ms
67,836 KB |
testcase_31 | AC | 664 ms
67,788 KB |
testcase_32 | AC | 662 ms
70,332 KB |
testcase_33 | AC | 535 ms
67,168 KB |
testcase_34 | AC | 685 ms
71,016 KB |
testcase_35 | AC | 616 ms
69,156 KB |
testcase_36 | AC | 762 ms
73,032 KB |
testcase_37 | AC | 314 ms
61,192 KB |
testcase_38 | AC | 769 ms
75,124 KB |
testcase_39 | AC | 654 ms
70,072 KB |
testcase_40 | AC | 693 ms
69,092 KB |
testcase_41 | AC | 842 ms
73,692 KB |
testcase_42 | AC | 771 ms
70,428 KB |
testcase_43 | AC | 844 ms
73,376 KB |
testcase_44 | AC | 980 ms
75,252 KB |
testcase_45 | AC | 869 ms
73,628 KB |
testcase_46 | AC | 843 ms
72,772 KB |
testcase_47 | AC | 894 ms
75,900 KB |
testcase_48 | AC | 872 ms
73,376 KB |
testcase_49 | AC | 900 ms
75,008 KB |
testcase_50 | AC | 849 ms
74,040 KB |
testcase_51 | AC | 872 ms
73,800 KB |
testcase_52 | AC | 1,006 ms
76,924 KB |
testcase_53 | AC | 910 ms
75,908 KB |
testcase_54 | AC | 910 ms
74,768 KB |
testcase_55 | AC | 1,018 ms
75,892 KB |
testcase_56 | AC | 818 ms
72,820 KB |
testcase_57 | AC | 937 ms
80,192 KB |
testcase_58 | AC | 894 ms
75,160 KB |
testcase_59 | AC | 852 ms
73,148 KB |
testcase_60 | AC | 1,013 ms
78,464 KB |
testcase_61 | AC | 56 ms
50,624 KB |
testcase_62 | AC | 56 ms
50,588 KB |
testcase_63 | AC | 846 ms
75,000 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()); } }