結果

問題 No.1791 Repeat Multiplication
コンテスト
ユーザー lanegue
提出日時 2021-12-24 22:20:26
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
AC  
実行時間 160 ms / 3,000 ms
+ 663µs
コード長 580 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 809 ms
コンパイル使用メモリ 210,048 KB
実行使用メモリ 27,648 KB
最終ジャッジ日時 2026-07-27 04:00:42
合計ジャッジ時間 6,048 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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