結果

問題 No.376 立方体のN等分 (2)
ユーザー rpy3cpp
提出日時 2016-06-05 10:45:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 754 ms / 5,000 ms
コード長 536 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 82,532 KB
実行使用メモリ 58,240 KB
最終ジャッジ日時 2024-11-06 22:06:00
合計ジャッジ時間 6,782 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

def solve(N):
    record = N - 1
    max_a = int(N**(1.0/3.0)) + 2
    for a in range(max_a, 0, -1):
        if N % a:
            continue
        bc = N // a
        max_b = int(bc ** 0.5) + 1
        if max_b * 2 + a - 6 > record:
            break
        for b in range(max_b, 0, -1):
            if bc % b:
                continue
            c = bc // b
            score = a + b + c - 3
            if score < record:
                record = score
            break
    return record, N - 1

print(*solve(N))
0