結果
問題 |
No.555 世界史のレポート
|
ユーザー |
![]() |
提出日時 | 2025-03-20 21:08:23 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 41 ms / 2,000 ms |
コード長 | 1,413 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 82,660 KB |
実行使用メモリ | 54,412 KB |
最終ジャッジ日時 | 2025-03-20 21:09:12 |
合計ジャッジ時間 | 1,786 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
import math n = int(input()) C, V = map(int, input().split()) min_cost = float('inf') max_k = 20 # This can be adjusted based on problem constraints def compute_product(m, k, t, n): product = 1 for _ in range(t): product *= (m + 1) if product > n: return product for _ in range(k - t): product *= m if product > n: return product return product for k in range(1, max_k + 1): if 2 ** k >= n: current_sum = 2 * k cost = V * current_sum + k * (C - V) if cost < min_cost: min_cost = cost continue left, right = 2, n best_m = 1 while left <= right: mid = (left + right) // 2 product = 1 over = False for _ in range(k): product *= mid if product > n: over = True break if not over: best_m = mid left = mid + 1 else: right = mid - 1 m = best_m found = False for t in range(0, k + 1): product = compute_product(m, k, t, n) if product >= n: current_sum = m * (k - t) + (m + 1) * t cost = V * current_sum + k * (C - V) if cost < min_cost: min_cost = cost found = True break if not found: pass print(min_cost)