結果

問題 No.1791 Repeat Multiplication
ユーザー ripityripity
提出日時 2021-11-21 15:41:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 675 ms / 3,000 ms
コード長 613 bytes
コンパイル時間 3,206 ms
コンパイル使用メモリ 72,012 KB
実行使用メモリ 95,120 KB
最終ジャッジ日時 2023-10-13 19:04:57
合計ジャッジ時間 22,843 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,928 KB
testcase_01 AC 127 ms
55,880 KB
testcase_02 AC 127 ms
55,528 KB
testcase_03 AC 132 ms
55,908 KB
testcase_04 AC 151 ms
55,856 KB
testcase_05 AC 169 ms
55,888 KB
testcase_06 AC 138 ms
55,956 KB
testcase_07 AC 151 ms
56,068 KB
testcase_08 AC 514 ms
63,172 KB
testcase_09 AC 493 ms
60,680 KB
testcase_10 AC 487 ms
61,024 KB
testcase_11 AC 476 ms
60,556 KB
testcase_12 AC 395 ms
60,848 KB
testcase_13 AC 666 ms
91,608 KB
testcase_14 AC 668 ms
91,976 KB
testcase_15 AC 645 ms
81,704 KB
testcase_16 AC 634 ms
80,760 KB
testcase_17 AC 675 ms
91,940 KB
testcase_18 AC 635 ms
85,872 KB
testcase_19 AC 643 ms
88,796 KB
testcase_20 AC 642 ms
81,572 KB
testcase_21 AC 652 ms
88,428 KB
testcase_22 AC 653 ms
95,120 KB
testcase_23 AC 634 ms
82,364 KB
testcase_24 AC 663 ms
92,724 KB
testcase_25 AC 645 ms
88,940 KB
testcase_26 AC 635 ms
94,032 KB
testcase_27 AC 629 ms
85,928 KB
testcase_28 AC 659 ms
92,476 KB
testcase_29 AC 642 ms
91,728 KB
testcase_30 AC 651 ms
92,312 KB
testcase_31 AC 126 ms
56,120 KB
testcase_32 AC 657 ms
91,812 KB
testcase_33 AC 643 ms
91,948 KB
testcase_34 AC 663 ms
92,212 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 = Integer.parseInt(sc.next());
			pw.println(dp[x]*sum[N/x]);
		}
		
		sc.close();
		pw.flush();
		
	}
	
}
0