結果

問題 No.375 立方体のN等分 (1)
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-06-05 11:51:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 285 ms / 5,000 ms
コード長 769 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-20 02:10:39
合計ジャッジ時間 3,734 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,880 KB
testcase_01 AC 25 ms
10,880 KB
testcase_02 AC 77 ms
10,880 KB
testcase_03 AC 26 ms
10,880 KB
testcase_04 AC 25 ms
10,880 KB
testcase_05 AC 26 ms
10,880 KB
testcase_06 AC 29 ms
10,880 KB
testcase_07 AC 39 ms
10,752 KB
testcase_08 AC 58 ms
10,880 KB
testcase_09 AC 55 ms
10,880 KB
testcase_10 AC 61 ms
10,880 KB
testcase_11 AC 71 ms
10,880 KB
testcase_12 AC 66 ms
10,880 KB
testcase_13 AC 71 ms
11,008 KB
testcase_14 AC 110 ms
11,008 KB
testcase_15 AC 75 ms
10,880 KB
testcase_16 AC 75 ms
10,880 KB
testcase_17 AC 197 ms
11,008 KB
testcase_18 AC 125 ms
11,008 KB
testcase_19 AC 85 ms
10,880 KB
testcase_20 AC 92 ms
11,008 KB
testcase_21 AC 88 ms
10,880 KB
testcase_22 AC 285 ms
11,008 KB
testcase_23 AC 91 ms
10,880 KB
testcase_24 AC 87 ms
10,880 KB
testcase_25 AC 87 ms
10,880 KB
testcase_26 AC 88 ms
10,880 KB
testcase_27 AC 84 ms
10,880 KB
testcase_28 AC 90 ms
11,008 KB
testcase_29 AC 93 ms
11,008 KB
testcase_30 AC 91 ms
10,880 KB
testcase_31 AC 94 ms
10,880 KB
testcase_32 AC 91 ms
10,880 KB
testcase_33 AC 86 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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()
0