結果
問題 |
No.375 立方体のN等分 (1)
|
ユーザー |
|
提出日時 | 2016-10-27 01:19:40 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 35 ms / 5,000 ms |
コード長 | 623 bytes |
コンパイル時間 | 1,687 ms |
コンパイル使用メモリ | 135,964 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 04:43:04 |
合計ジャッジ時間 | 2,532 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 |
ソースコード
import std.stdio; import std.conv; import std.math; void main() { ulong n; readf("%s", &n); ulong tmax = n-1; ulong tmin = tmax; ulong[] d = [1]; foreach (i; 2..n.to!double.sqrt().to!ulong + 1) { if (0 != n % i) { continue; } d ~= i; } ulong nd = d.length; foreach (i; 0..nd) { foreach (j; i..nd) { ulong a = d[i]; ulong b = d[j]; if (0 != n % (a*b)) { continue; } ulong c = n / a / b; ulong x = a + b + c - 3; tmin = (tmin <= x) ? tmin : x; } } writeln(tmin, " ", tmax); }