Codey and Money
https://www.hackerrank.com/contests/codenection-2023-preliminary-round-closed-category/challenges/cn-c5
Question
Codey is planning a trip to Penang, and it needs to gather exactly n ringgits for its exciting journey. However, it only has access to a limited number of ringgit bills, each of which is a power of . The ringgit bills that Codey has been defined by an array a with a length of k, where represents the number of ringgit bills that Codey possesses.
For example, when , Codey has three ringgit bills, two ringgit bills, and one ringgit bill.
Codey would like you to determine if it's possible to obtain precisely n ringgits for its trip using the ringgit bills it has.
Input Format
The first line contains an integer t, which represents the number of test cases.
The following provides the description of each test case:
The first line contains an integer
k, which represents the length of arraya.The second line contains an integer
n, which represents the final amount Codey needs.The third line contains
kintegers , each representing the number of ringgit bills.
Constraints
It is guaranteed that the sum of
kover all test cases does not exceed5 * 10^5.
Output Format
Outputs YES for test case if it's possible to obtain n ringgits, otherwise output NO.
Sample Inputs:
Last updated