結果

問題 No.376 立方体のN等分 (2)
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-06-05 11:55:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 591 ms / 5,000 ms
コード長 767 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 82,388 KB
実行使用メモリ 76,032 KB
最終ジャッジ日時 2024-04-24 13:48:05
合計ジャッジ時間 11,818 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,352 KB
testcase_01 AC 38 ms
52,224 KB
testcase_02 AC 253 ms
57,984 KB
testcase_03 AC 249 ms
60,928 KB
testcase_04 AC 286 ms
59,520 KB
testcase_05 AC 39 ms
52,224 KB
testcase_06 AC 40 ms
51,712 KB
testcase_07 AC 39 ms
52,224 KB
testcase_08 AC 53 ms
57,728 KB
testcase_09 AC 94 ms
58,112 KB
testcase_10 AC 149 ms
75,524 KB
testcase_11 AC 152 ms
57,984 KB
testcase_12 AC 190 ms
58,752 KB
testcase_13 AC 193 ms
57,856 KB
testcase_14 AC 209 ms
58,112 KB
testcase_15 AC 230 ms
57,984 KB
testcase_16 AC 516 ms
76,032 KB
testcase_17 AC 254 ms
57,600 KB
testcase_18 AC 260 ms
57,728 KB
testcase_19 AC 270 ms
59,392 KB
testcase_20 AC 271 ms
57,984 KB
testcase_21 AC 550 ms
75,392 KB
testcase_22 AC 280 ms
57,856 KB
testcase_23 AC 565 ms
75,776 KB
testcase_24 AC 562 ms
75,776 KB
testcase_25 AC 290 ms
57,344 KB
testcase_26 AC 591 ms
76,032 KB
testcase_27 AC 292 ms
57,984 KB
testcase_28 AC 292 ms
58,112 KB
testcase_29 AC 292 ms
57,856 KB
testcase_30 AC 295 ms
57,856 KB
testcase_31 AC 293 ms
57,984 KB
testcase_32 AC 293 ms
57,472 KB
testcase_33 AC 294 ms
57,600 KB
testcase_34 AC 295 ms
57,984 KB
testcase_35 AC 295 ms
57,728 KB
testcase_36 AC 295 ms
57,728 KB
testcase_37 AC 293 ms
57,472 KB
testcase_38 AC 292 ms
57,600 KB
testcase_39 AC 293 ms
57,728 KB
権限があれば一括ダウンロードができます

ソースコード

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