#P8799. [蓝桥杯 2022 国 B] 齿轮
[蓝桥杯 2022 国 B] 齿轮
Problem Description
On this day, Xiaoming is assembling gears.
He has a total of gears. The radius of the -th gear is . He needs to assemble these gears in some order from left to right, so that after the leftmost gear starts rotating, the motion can be transmitted to the rightmost gear. Also, these gears can be used to increase or decrease the rotation speed (angular velocity).

Looking at these gears, Xiaoming suddenly has questions: Is it possible to assemble these gears in some order so that the rotation speed of the rightmost gear is times that of the leftmost gear?
Input Format
The input has lines. The first line contains two positive integers , representing the number of gears and the number of queries.
The second line contains positive integers , representing the radius of each gear.
The next lines each contain one positive integer , representing a query.
Output Format
Output lines. For each query, if there exists at least one assembly plan that satisfies the condition, output YES; otherwise output NO.
5 3
4 2 3 3 1
2
4
6
YES
YES
NO
Hint
[Sample Explanation]
For query , one possible plan is: 23341.
For query , one possible plan is: 42331.
For query , there is no plan.
[Constraints and Notes on Testdata]
For of the testdata, it is guaranteed that .
For of the testdata, it is guaranteed that .
For of the testdata, , , and .
Lanqiao Cup 2022 National Finals, Group B, Problem I.
Translated by ChatGPT 5