結果

問題 No.1791 Repeat Multiplication
ユーザー laneguelanegue
提出日時 2021-12-24 22:20:26
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 257 ms / 3,000 ms
コード長 580 bytes
コンパイル時間 3,350 ms
コンパイル使用メモリ 223,432 KB
実行使用メモリ 30,436 KB
最終ジャッジ日時 2023-09-04 15:33:40
合計ジャッジ時間 9,797 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 54 ms
6,044 KB
testcase_09 AC 49 ms
5,824 KB
testcase_10 AC 49 ms
5,736 KB
testcase_11 AC 44 ms
5,736 KB
testcase_12 AC 26 ms
5,060 KB
testcase_13 AC 212 ms
29,148 KB
testcase_14 AC 230 ms
27,076 KB
testcase_15 AC 152 ms
21,396 KB
testcase_16 AC 153 ms
22,276 KB
testcase_17 AC 231 ms
29,160 KB
testcase_18 AC 176 ms
24,392 KB
testcase_19 AC 228 ms
28,196 KB
testcase_20 AC 170 ms
23,292 KB
testcase_21 AC 217 ms
27,388 KB
testcase_22 AC 222 ms
28,956 KB
testcase_23 AC 164 ms
22,776 KB
testcase_24 AC 212 ms
28,488 KB
testcase_25 AC 198 ms
26,604 KB
testcase_26 AC 230 ms
28,452 KB
testcase_27 AC 183 ms
25,056 KB
testcase_28 AC 257 ms
30,436 KB
testcase_29 AC 256 ms
30,060 KB
testcase_30 AC 230 ms
29,360 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 230 ms
29,440 KB
testcase_33 AC 245 ms
29,444 KB
testcase_34 AC 229 ms
29,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main(){
	auto input = readln.chomp.split(" ");
	auto N = input[0].to!long;
	auto Q = input[1].to!int;
	auto count = new long[N + 1];
	count[1] = 1;
	for(auto n = 1; n <= N; n++){
		for(auto m = n * 2; m <= N; m += n){
			count[m] += count[n];
		}
	}
	//stderr.writeln(count);
	auto reverse = new long[N + 1];
	for(auto n = N; n > 0; n--){
		reverse[n] = 1;
		for(auto m = n * 2; m <= N; m += n){
			reverse[n] += reverse[m];
		}
	}
	//stderr.writeln(reverse);
	for(auto q = 0; q < Q; q++){
		auto x = readln.chomp.to!long;
		writeln(count[x] * reverse[x]);
	}
}
0