#P2001. 硬币的面值

硬币的面值

Description

Xiao A has nn types of coins and wants to buy an item priced at no more than mm yuan. He does not want to receive change (it’s dirty), and he also does not want to carry too many coins. Each denomination can be used repeatedly. Given the denominations of these nn types of coins, what is the minimum number of coins needed so that all prices from 11 to mm can be formed exactly?

Input Format

The first line contains two integers: n,mn, m.

The next line contains nn integers, the coin denominations.

Output Format

Output a single integer: the minimum number of coins. If there is no solution, output No answer!!!.

5 31
1 2 8 4 16

5

Hint

Constraints

Only testcases 9 and 10 are designed to trip people; greedy is fine.

For 20%20\% of the testdata, 1n101 \le n \le 10, 1m1001 \le m \le 100.
For 60%60\% of the testdata, 1n10001 \le n \le 1000, 1m100001 \le m \le 10000.
For 80%80\% of the testdata, 1n300001 \le n \le 30000, 1m2×1091 \le m \le 2 \times 10^9.
For 100%100\% of the testdata, 1n2×1051 \le n \le 2 \times 10^5, 1m2631 \le m \le 2^{63}.

Translated by ChatGPT 5