結果

問題 No.1791 Repeat Multiplication
ユーザー ripityripity
提出日時 2021-11-21 15:35:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,269 ms / 3,000 ms
コード長 516 bytes
コンパイル時間 2,011 ms
コンパイル使用メモリ 72,540 KB
実行使用メモリ 89,348 KB
最終ジャッジ日時 2023-10-13 19:04:02
合計ジャッジ時間 36,373 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,980 KB
testcase_01 AC 125 ms
55,440 KB
testcase_02 AC 125 ms
55,972 KB
testcase_03 AC 139 ms
55,708 KB
testcase_04 AC 180 ms
54,020 KB
testcase_05 AC 191 ms
55,672 KB
testcase_06 AC 146 ms
55,756 KB
testcase_07 AC 170 ms
55,980 KB
testcase_08 AC 1,020 ms
68,828 KB
testcase_09 AC 959 ms
64,644 KB
testcase_10 AC 948 ms
66,032 KB
testcase_11 AC 898 ms
66,656 KB
testcase_12 AC 709 ms
61,000 KB
testcase_13 AC 1,201 ms
89,348 KB
testcase_14 AC 1,215 ms
80,980 KB
testcase_15 AC 1,129 ms
84,464 KB
testcase_16 AC 1,089 ms
81,188 KB
testcase_17 AC 1,177 ms
79,656 KB
testcase_18 AC 1,088 ms
86,108 KB
testcase_19 AC 1,170 ms
75,716 KB
testcase_20 AC 1,156 ms
70,116 KB
testcase_21 AC 1,159 ms
75,980 KB
testcase_22 AC 1,235 ms
78,208 KB
testcase_23 AC 1,180 ms
70,956 KB
testcase_24 AC 1,188 ms
76,428 KB
testcase_25 AC 1,113 ms
74,692 KB
testcase_26 AC 1,240 ms
78,084 KB
testcase_27 AC 1,124 ms
72,116 KB
testcase_28 AC 1,223 ms
78,372 KB
testcase_29 AC 1,199 ms
78,248 KB
testcase_30 AC 1,157 ms
79,092 KB
testcase_31 AC 124 ms
39,240 KB
testcase_32 AC 1,218 ms
79,160 KB
testcase_33 AC 1,163 ms
78,720 KB
testcase_34 AC 1,269 ms
78,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		long[] dp = new long[N+1];
		long[] sum = new long[N+1];
		dp[1] = 1;
		for( int i = 1; i <= N; i++ ) {
			sum[i] = dp[i]+sum[i-1];
			for( int j = 2; i*j <= N; j++ ) {
				dp[i*j] += dp[i];
			}
		}
		
		for( int i = 0; i < Q; i++ ) {
		    int x = sc.nextInt();
			System.out.println(dp[x]*sum[N/x]);
		}
		
		sc.close();
		
	}
	
}
0