結果

問題 No.375 立方体のN等分 (1)
コンテスト
ユーザー Tosuke
提出日時 2016-06-10 01:49:38
言語 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
結果
WA  
実行時間 -
コード長 620 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,862 ms
コンパイル使用メモリ 122,596 KB
実行使用メモリ 10,144 KB
最終ジャッジ日時 2026-03-05 07:01:24
合計ジャッジ時間 30,454 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21 WA * 7 TLE * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.d(28): Deprecation: foreach: loop index implicitly converted from `size_t` to `uint`
            foreach(uint i, y; v[]){
            ^

ソースコード

diff #
raw source code

import std.algorithm;
import std.stdio;
import std.conv;
import std.string;
import std.typecons;

void main(){
	auto n = readln.strip.to!ulong;
	auto max = n - 1;
	
	auto r = (a){
		import std.container;
		SList!ulong v;
		ulong i = 2;
		while(a != 1){
			while(a % i == 0){
				v.insertFront(i);
				a /= i;
			}
			i++;
		}
		return v;
	}(n);
	ulong[] v = [1, 1, 1];
	foreach(a; r[]){
		auto k = (){
			ulong bf = ulong.max , t;
			foreach(uint i, y; v[]){
				t = y < bf ? i : t;
				bf = y < bf ? y : bf;
			}
			return t;
		}();
		v[k.to!uint] *= a;
	}
	auto min = v.map!("a-1").sum;
	
	writef("%d %d", min, max);
}
0