結果
| 問題 |
No.376 立方体のN等分 (2)
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:41:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 823 bytes |
| コンパイル時間 | 183 ms |
| コンパイル使用メモリ | 82,676 KB |
| 実行使用メモリ | 76,704 KB |
| 最終ジャッジ日時 | 2025-03-31 17:43:21 |
| 合計ジャッジ時間 | 19,187 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 TLE * 4 -- * 13 |
ソースコード
import math
def find_min_T(N):
min_sum = float('inf')
max_a = int(N ** (1/3)) + 2 # Add 2 to handle floating point inaccuracies
for a in range(1, max_a + 1):
if N % a != 0:
continue
M = N // a
max_b = int(math.isqrt(M)) # Compute sqrt(M) once
# b must be >= a and <= max_b, and also a factor of M
for b in range(a, max_b + 1):
if M % b != 0:
continue
c = M // b
if c < b:
continue # Ensure a <= b <= c
current_sum = a + b + c - 3
if current_sum < min_sum:
min_sum = current_sum
return min_sum
def main():
N = int(input().strip())
Tmax = N - 1
Tmin = find_min_T(N)
print(f"{Tmin} {Tmax}")
if __name__ == "__main__":
main()
lam6er