結果

問題 No.376 立方体のN等分 (2)
ユーザー はむ吉🐹
提出日時 2016-06-05 11:55:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 595 ms / 5,000 ms
コード長 767 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 76,160 KB
最終ジャッジ日時 2024-11-06 22:06:20
合計ジャッジ時間 11,880 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env pypy3

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()
0