結果

問題 No.376 立方体のN等分 (2)
ユーザー H3PO4
提出日時 2020-07-10 09:27:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,974 ms / 5,000 ms
コード長 390 bytes
コンパイル時間 755 ms
コンパイル使用メモリ 82,068 KB
実行使用メモリ 76,080 KB
最終ジャッジ日時 2024-10-09 20:38:01
合計ジャッジ時間 15,496 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools


def isqrt(n):
    x = n
    y = (x + 1) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x


N = int(input())

div = [i for i in range(1, isqrt(N) + 1) if not N % i]

Nmin = Nmax = N - 1
for i, j in itertools.combinations_with_replacement(div, 2):
    if not N % (i * j):
        Nmin = min(Nmin, i + j + (N // (i * j)) - 3)
print(Nmin, Nmax)
0