結果

問題 No.1791 Repeat Multiplication
ユーザー tentententen
提出日時 2023-12-06 16:17:02
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,118 bytes
コンパイル時間 4,597 ms
コンパイル使用メモリ 91,792 KB
実行使用メモリ 74,656 KB
最終ジャッジ日時 2023-12-06 16:17:23
合計ジャッジ時間 17,889 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
53,964 KB
testcase_01 AC 54 ms
53,992 KB
testcase_02 AC 55 ms
53,980 KB
testcase_03 AC 54 ms
53,984 KB
testcase_04 AC 57 ms
53,988 KB
testcase_05 AC 57 ms
52,040 KB
testcase_06 AC 54 ms
53,976 KB
testcase_07 AC 64 ms
53,984 KB
testcase_08 AC 254 ms
61,368 KB
testcase_09 AC 239 ms
61,320 KB
testcase_10 AC 320 ms
61,376 KB
testcase_11 AC 334 ms
64,228 KB
testcase_12 AC 187 ms
59,608 KB
testcase_13 AC 364 ms
72,256 KB
testcase_14 AC 369 ms
72,256 KB
testcase_15 AC 356 ms
68,252 KB
testcase_16 AC 328 ms
67,796 KB
testcase_17 AC 374 ms
72,260 KB
testcase_18 AC 368 ms
70,208 KB
testcase_19 AC 363 ms
72,252 KB
testcase_20 AC 339 ms
68,888 KB
testcase_21 AC 391 ms
72,256 KB
testcase_22 AC 370 ms
70,320 KB
testcase_23 WA -
testcase_24 AC 395 ms
72,252 KB
testcase_25 AC 346 ms
72,256 KB
testcase_26 AC 375 ms
72,256 KB
testcase_27 AC 372 ms
70,196 KB
testcase_28 AC 381 ms
74,436 KB
testcase_29 AC 367 ms
74,568 KB
testcase_30 AC 397 ms
74,572 KB
testcase_31 AC 52 ms
53,992 KB
testcase_32 AC 362 ms
74,420 KB
testcase_33 AC 371 ms
74,572 KB
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
    }
    
}
0