結果
問題 | No.1791 Repeat Multiplication |
ユーザー | tenten |
提出日時 | 2023-12-06 16:17:02 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,118 bytes |
コンパイル時間 | 6,075 ms |
コンパイル使用メモリ | 92,204 KB |
実行使用メモリ | 59,896 KB |
最終ジャッジ日時 | 2024-09-27 01:32:01 |
合計ジャッジ時間 | 15,652 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 49 ms
37,024 KB |
testcase_01 | AC | 49 ms
36,752 KB |
testcase_02 | AC | 51 ms
36,828 KB |
testcase_03 | AC | 50 ms
37,028 KB |
testcase_04 | AC | 51 ms
36,948 KB |
testcase_05 | AC | 55 ms
37,060 KB |
testcase_06 | AC | 55 ms
36,752 KB |
testcase_07 | AC | 54 ms
37,212 KB |
testcase_08 | AC | 218 ms
47,600 KB |
testcase_09 | AC | 290 ms
47,552 KB |
testcase_10 | AC | 242 ms
46,908 KB |
testcase_11 | AC | 237 ms
46,824 KB |
testcase_12 | AC | 175 ms
48,792 KB |
testcase_13 | AC | 341 ms
57,892 KB |
testcase_14 | AC | 341 ms
58,324 KB |
testcase_15 | AC | 310 ms
54,688 KB |
testcase_16 | AC | 309 ms
54,408 KB |
testcase_17 | AC | 335 ms
58,640 KB |
testcase_18 | AC | 323 ms
56,200 KB |
testcase_19 | AC | 332 ms
57,840 KB |
testcase_20 | AC | 307 ms
55,080 KB |
testcase_21 | AC | 326 ms
57,528 KB |
testcase_22 | AC | 340 ms
58,492 KB |
testcase_23 | WA | - |
testcase_24 | AC | 339 ms
58,188 KB |
testcase_25 | AC | 345 ms
57,016 KB |
testcase_26 | AC | 349 ms
58,156 KB |
testcase_27 | AC | 345 ms
55,972 KB |
testcase_28 | AC | 355 ms
59,624 KB |
testcase_29 | AC | 344 ms
59,516 KB |
testcase_30 | AC | 349 ms
59,896 KB |
testcase_31 | AC | 50 ms
37,132 KB |
testcase_32 | AC | 349 ms
59,668 KB |
testcase_33 | AC | 344 ms
59,664 KB |
testcase_34 | WA | - |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int q = sc.nextInt(); int[] lefts = new int[n + 1]; lefts[1] = 1; for (int i = 1; i <= n; i++) { for (int j = 2; j * i <= n; j++) { lefts[j * i] += lefts[i]; } } int[] rights = new int[n + 1]; for (int i = n; i >= 1; i--) { rights[i] = 1; for (int j = 2; j * i <= n; j++) { rights[i] += rights[j * i]; } } StringBuilder sb = new StringBuilder(); while (q-- > 0) { int x = sc.nextInt(); sb.append((long)lefts[x] * rights[x]).append("\n"); } System.out.print(sb); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }