結果

問題 No.375 立方体のN等分 (1)
ユーザー lam6er
提出日時 2025-04-16 15:52:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 194 ms / 5,000 ms
コード長 661 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 81,984 KB
実行使用メモリ 65,464 KB
最終ジャッジ日時 2025-04-16 15:53:47
合計ジャッジ時間 3,322 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

N = int(input())

tmax = N - 1
tmin = float('inf')

a_max = int(N ** (1/3)) + 2  # Adding 2 to ensure we cover the cube root

for a in range(1, a_max + 1):
    if N % a != 0:
        continue
    M = N // a
    b_max = int(math.isqrt(M))
    for b in range(a, b_max + 1):
        if M % b != 0:
            continue
        c = M // b
        if b <= c:
            current_sum = a + b + c
            if current_sum < tmin:
                tmin = current_sum

# Ensure the minimal case is considered even if all factors are larger than cube root
if tmin == float('inf'):
    tmin = 1 + 1 + N  # Fallback to 1,1,N case

tmin -= 3

print(tmin, tmax)
0