結果

問題 No.376 立方体のN等分 (2)
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-06-05 11:52:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 4,668 ms / 5,000 ms
コード長 769 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-04-17 04:41:39
合計ジャッジ時間 76,039 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 1,692 ms
10,752 KB
testcase_03 AC 1,649 ms
10,752 KB
testcase_04 AC 1,971 ms
10,880 KB
testcase_05 AC 29 ms
10,752 KB
testcase_06 AC 27 ms
10,880 KB
testcase_07 AC 28 ms
10,752 KB
testcase_08 AC 117 ms
10,752 KB
testcase_09 AC 445 ms
10,880 KB
testcase_10 AC 781 ms
11,008 KB
testcase_11 AC 903 ms
10,752 KB
testcase_12 AC 1,179 ms
10,752 KB
testcase_13 AC 1,245 ms
10,880 KB
testcase_14 AC 1,404 ms
10,880 KB
testcase_15 AC 1,600 ms
10,752 KB
testcase_16 AC 4,074 ms
11,520 KB
testcase_17 AC 1,724 ms
10,752 KB
testcase_18 AC 1,853 ms
10,752 KB
testcase_19 AC 1,820 ms
10,752 KB
testcase_20 AC 2,053 ms
10,752 KB
testcase_21 AC 4,362 ms
11,648 KB
testcase_22 AC 2,194 ms
10,752 KB
testcase_23 AC 4,604 ms
11,520 KB
testcase_24 AC 4,430 ms
11,520 KB
testcase_25 AC 2,110 ms
10,752 KB
testcase_26 AC 4,668 ms
11,520 KB
testcase_27 AC 2,164 ms
10,752 KB
testcase_28 AC 2,111 ms
10,752 KB
testcase_29 AC 2,043 ms
10,752 KB
testcase_30 AC 2,009 ms
10,752 KB
testcase_31 AC 2,094 ms
10,752 KB
testcase_32 AC 2,270 ms
10,752 KB
testcase_33 AC 2,237 ms
10,880 KB
testcase_34 AC 2,094 ms
10,752 KB
testcase_35 AC 2,103 ms
10,752 KB
testcase_36 AC 2,133 ms
10,752 KB
testcase_37 AC 2,211 ms
10,752 KB
testcase_38 AC 1,997 ms
10,752 KB
testcase_39 AC 2,009 ms
10,752 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