프로그램 명: boi_coins
제한시간: 1 초

In a certain country, there are N denominations of coins in circulation, including the 1-cent coin.

Additionally, there’s a bill whose value of K cents is known to exceed any of the coins. There’s a coin collector who wants to collect a specimen of each denomination of coins. He already has a few coins at home, but currently he only carries one K-cent bill in his wallet. He’s in a shop where there are items sold at all prices less than K cents (1 cent, 2 cents, 3 cents, … , K i 1 cents). In this shop, the change is given using the following algorithm:

  1. Let the amount of change to give be A cents.
  2. Find the highest denomination that does not exceed A. (Let it be the B-cent coin.)
  3. Give the customer a B-cent coin and reduce A by B.
  4. If A = 0, then end; otherwise return to step 2.
The coin collector buys one item, paying with his K-cent bill.

Your task is to write a program that determines:

입력

출력

The first line of the output file 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 file 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.

입출력 예

입력

7 25
1 0
2 0
3 1
5 0
10 0
13 0
20 0

출력

3
6
출처:boi 2006

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]