結果

問題 No.1791 Repeat Multiplication
ユーザー ripityripity
提出日時 2021-11-21 15:39:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 684 ms / 3,000 ms
コード長 598 bytes
コンパイル時間 4,704 ms
コンパイル使用メモリ 70,996 KB
実行使用メモリ 89,704 KB
最終ジャッジ日時 2023-10-13 19:03:21
合計ジャッジ時間 25,227 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
55,456 KB
testcase_01 AC 114 ms
55,676 KB
testcase_02 AC 107 ms
56,412 KB
testcase_03 AC 106 ms
55,880 KB
testcase_04 AC 136 ms
56,484 KB
testcase_05 AC 149 ms
56,264 KB
testcase_06 AC 111 ms
55,924 KB
testcase_07 AC 133 ms
55,968 KB
testcase_08 AC 506 ms
62,520 KB
testcase_09 AC 451 ms
60,384 KB
testcase_10 AC 461 ms
60,744 KB
testcase_11 AC 441 ms
60,684 KB
testcase_12 AC 387 ms
60,324 KB
testcase_13 AC 684 ms
86,428 KB
testcase_14 AC 644 ms
78,272 KB
testcase_15 AC 588 ms
80,068 KB
testcase_16 AC 598 ms
78,424 KB
testcase_17 AC 635 ms
80,024 KB
testcase_18 AC 610 ms
83,584 KB
testcase_19 AC 628 ms
87,148 KB
testcase_20 AC 603 ms
77,644 KB
testcase_21 AC 579 ms
74,528 KB
testcase_22 AC 658 ms
82,624 KB
testcase_23 AC 627 ms
76,704 KB
testcase_24 AC 610 ms
76,732 KB
testcase_25 AC 610 ms
86,540 KB
testcase_26 AC 657 ms
85,184 KB
testcase_27 AC 579 ms
82,660 KB
testcase_28 AC 681 ms
77,788 KB
testcase_29 AC 643 ms
89,176 KB
testcase_30 AC 598 ms
88,008 KB
testcase_31 AC 99 ms
51,908 KB
testcase_32 AC 632 ms
76,156 KB
testcase_33 AC 616 ms
89,704 KB
testcase_34 AC 633 ms
85,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.io.PrintWriter;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		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();
			pw.println(dp[x]*sum[N/x]);
		}
		
		sc.close();
		pw.flush();
		
	}
	
}
0