#P1490. 买蛋糕
买蛋糕
Description
It’s Wildcat’s birthday, and of course everyone is bringing gifts (ahem, those who didn’t, take note!). Not knowing what to buy and considering practicality, everyone decides to chip in to buy Wildcat a birthday cake. They don’t know the exact price of the cake, but they can set a price estimate, i.e., they will buy a cake that does not exceed a certain amount. The OIers then pose a challenge: can we use the fewest number of coins to make all values within the estimate range, so that no matter the cake’s price, no change is needed?
This leads to the following problem: for a given , can we use the fewest distinct positive integers to form all positive integers up to and including ? If yes, what is the minimal number of positive integers required, and with that minimal number, how many different ways are there?
Input Format
A single line containing an integer .
Output Format
One line with two numbers: the first is the minimal required count, and the second is the number of compositions using that minimal count. The two answers are separated by a space.
6
3 2
Hint
Using three numbers is minimal; there are two methods: and .
- For there are ,,,.
- For there are ,,,,,.
Translated by ChatGPT 5
京公网安备 11011102002149号