#P5949. [BalticOI 2000] Division expression
[BalticOI 2000] Division expression
Description
A division expression has the following form:
, where are positive integers and . The division expression should be evaluated from left to right.
For example, the value of the expression is .
However, you can add parentheses to the expression to change the order of evaluation. For example, the value of is . Now you are given a division expression . Determine whether it is possible to make its result an integer by adding parentheses.
Input Format
The first line contains an integer , meaning there are test cases.
For each test case, a number is given first, meaning this test case contains numbers.
Then the next line contains numbers.
Output Format
If the value of the expression can be made an integer, output YES; otherwise, output NO.
2
4
1
2
1
2
3
1
2
3
YES
NO
Hint
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号