#P9863. Minimum Time to Exceed Target Items
Minimum Time to Exceed Target Items
Minimum Time to Exceed Target Items
You are given an initial count of \(1\) item. You can perform two types of operations repeatedly to increase the number of items until it becomes greater than \(n\). The operations are defined as follows:
- Store Operation (Choice 1): Set the database value to the current number of items. This operation costs \(a\) units of time.
- Addition Operation (Choice 2): Increase the current number of items by the value stored in the database. This operation costs \(b\) units of time.
Note: Initially, the database is empty, so you must perform a store operation before you can use the addition operation.
Your task is to calculate the minimum total time required such that the number of items becomes strictly greater than \(n\). All formulas in this problem are formatted in \(\LaTeX\) (for example, the initial items is \(1\) and the goal is to exceed \(n\)).
Hint: A good strategy is to decide greedily at each step whether to perform a sequence of additions to finish or to invest extra time in updating the database (which increases the boost in subsequent addition operations). One useful parameter is \(k = \lfloor \frac{a}{b} \rfloor + 1\); this value helps decide whether an update-pair (i.e. a sequence of several additions followed by a store operation and one more addition) is beneficial.
inputFormat
The input consists of three space-separated integers:
- \(n\) — the target threshold (your goal is to have more than \(n\) items),
- \(a\) — the time cost of a store operation, and
- \(b\) — the time cost of an addition operation.
outputFormat
Output a single integer representing the minimum total time required to obtain strictly more than \(n\) items.
sample
1 1 1
2