Baltic Olympiad in Informatics: 2006 Day 1, Problem 2
In a certain country, there are
- Let the amount of change to give be
cents. - Find the highest denomination that does not exceed
. (Let it be the -cent coin.) - Give the customer a
-cent coin and reduce by . - If
, then end; otherwise return to step .
The coin collector buys one item, paying with his
Your task is to write a program that determines:
- How many different coins that the collector does not yet have in his collection can he acquire with this transaction?
- What is the most expensive item the store can sell him in the process?
Input
The first line of the input
contains the integers
Output
The first line of the output should contain a single integer — the maximal number of denominations that the collector does not yet have, but could acquire with a single purchase. The second line of the output should also contain a single integer — the maximal price of the item to buy so that the change given would include the maximal number of new denominations, as declared on the first line.
Sample Input
7 25
1 0
2 0
3 1
5 0
10 0
13 0
20 0
Sample Output
3
6
Comments