#d11003. 货币系统
货币系统
Currency Systems
Problem Description
During the May Day holiday, little visits countries. He finds that each country has its own currency system — a set of denominations, such as China's .
Assume little has an infinite supply of each denomination. When buying something of value , because his math is not great, he always picks the largest denomination that does not exceed the remaining amount to pay, repeating until the payment is complete.
For example, with currency system and item value , little will pay using coins of denominations in order.
We say little is "smart" in a country if, for items of any value, there is no other payment scheme that uses strictly fewer coins than his method. (It is guaranteed that each country has a denomination of , so any value can be paid.)
Given the currency systems, determine whether little is smart in each country.
Input Format
The first line contains a positive integer , the number of countries.
For each country:
- The first line contains a positive integer , the size of the currency system.
- The next line contains positive integers , the denominations.
Output Format
For each country, output one line with a string: if little is smart in this country, output Yes; otherwise output No.
You may output in any case, such as YES, yEs, NO, etc.
Sample Input
3
3
1 2 5
4
1 3 8 13
4
1 3 4 10
Sample Output
Yes
Yes
No
Sample Explanation
For the third country, when buying an item of value , little 's method uses . However, there is a payment using fewer coins.
Constraints
For all data: , , , and .