結果
問題 | No.376 立方体のN等分 (2) |
ユーザー |
![]() |
提出日時 | 2016-06-05 11:52:52 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 4,613 ms / 5,000 ms |
コード長 | 769 bytes |
コンパイル時間 | 426 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 11,520 KB |
最終ジャッジ日時 | 2024-10-08 15:26:00 |
合計ジャッジ時間 | 75,327 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 |
ソースコード
#!/usr/bin/env python3 import math def divisors(n): xs = [] for i in range(1, math.ceil(math.sqrt(n)) + 1): d, m = divmod(n, i) if m == 0: xs.append(i) if i * i != n: xs.append(d) xs.sort() return xs def compute_max(n): return n - 1 def compute_min(n): ds = divisors(n) ans = compute_max(n) for a in ds: if a * a * a > n: break for b in ds: if a * b * b > n: break c, m = divmod(n, a * b) if m == 0: ans = min(ans, a + b + c - 3) return ans def main(): n = int(input()) print("{} {}".format(compute_min(n), compute_max(n))) if __name__ == '__main__': main()