結果
問題 | 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 mathn = int(input())C, V = map(int, input().split())min_cost = float('inf')max_k = 20 # This can be adjusted based on problem constraintsdef compute_product(m, k, t, n):product = 1for _ in range(t):product *= (m + 1)if product > n:return productfor _ in range(k - t):product *= mif product > n:return productreturn productfor k in range(1, max_k + 1):if 2 ** k >= n:current_sum = 2 * kcost = V * current_sum + k * (C - V)if cost < min_cost:min_cost = costcontinueleft, right = 2, nbest_m = 1while left <= right:mid = (left + right) // 2product = 1over = Falsefor _ in range(k):product *= midif product > n:over = Truebreakif not over:best_m = midleft = mid + 1else:right = mid - 1m = best_mfound = Falsefor t in range(0, k + 1):product = compute_product(m, k, t, n)if product >= n:current_sum = m * (k - t) + (m + 1) * tcost = V * current_sum + k * (C - V)if cost < min_cost:min_cost = costfound = Truebreakif not found:passprint(min_cost)