#P8072. Chocolate Cutting Optimization
Chocolate Cutting Optimization
Chocolate Cutting Optimization
A customer urgently needs chocolate amounting to (K) units. However, you are only allowed to purchase a single chocolate block whose size is a power of two, i.e. (1,2,4,8,16,\ldots) (note that these sizes can be represented as (2^0,2^1,2^2,\ldots)).
To meet the customer's demand, you are permitted to perform cutting operations. In each operation, you can split a chocolate block of size (D) into two blocks, each of size (\frac{D}{2}).
Your task is to determine two values:
- The minimum size of the purchased chocolate block (which must be a power of two) so that, after a series of cuts, you can obtain pieces that sum exactly to \(K\) units.
- The minimum number of cuts required to achieve this.
Note that you may discard extra pieces if they are not needed to sum up to \(K\). All formulas are in \(\LaTeX\) format.
inputFormat
The input consists of a single integer (K) ( (1 \leq K \leq 10^9) ), representing the required number of chocolate units.
outputFormat
Output two integers separated by a space: the minimum chocolate block size (a power of two) that must be purchased, and the minimum number of cuts needed.
sample
1
1 0