結果
問題 |
No.376 立方体のN等分 (2)
|
ユーザー |
![]() |
提出日時 | 2025-04-16 16:29:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 684 ms / 5,000 ms |
コード長 | 744 bytes |
コンパイル時間 | 351 ms |
コンパイル使用メモリ | 81,440 KB |
実行使用メモリ | 68,224 KB |
最終ジャッジ日時 | 2025-04-16 16:31:21 |
合計ジャッジ時間 | 7,428 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 |
ソースコード
import math def find_Tmin(N): min_sum = float('inf') max_a = int(N ** (1/3)) + 2 # Adding 2 to ensure we cover the cube root for a in range(1, max_a + 1): if N % a != 0: continue M = N // a sqrt_M = int(math.isqrt(M)) b = None # Find the largest b <= sqrt(M) and >= a for i in range(sqrt_M, 0, -1): if M % i == 0 and i >= a: b = i break if b is None: continue c = M // b current_sum = a + b + c if current_sum < min_sum: min_sum = current_sum return min_sum - 3 if min_sum != float('inf') else 0 N = int(input()) Tmax = N - 1 Tmin = find_Tmin(N) print(Tmin, Tmax)