P5949 [BalticOI 2000] Division expression
Description
A division expression has the following form:
$X_1/X_2/X_3.../X_n$, where $X_i$ are positive integers and $X_i \le 10^9$. The division expression should be evaluated from left to right.
For example, the value of the expression $1/2/1/2$ is $1/4$.
However, you can add parentheses to the expression to change the order of evaluation. For example, the value of $(1/2)/(1/2)$ is $1$. Now you are given a division expression $E$. Determine whether it is possible to make its result an integer by adding parentheses.
Input Format
The first line contains an integer $D$, meaning there are $D$ test cases.
For each test case, a number $N$ is given first, meaning this test case contains $N$ numbers.
Then the next line contains $N$ numbers.
Output Format
If the value of the expression can be made an integer, output `YES`; otherwise, output `NO`.
Explanation/Hint
For $100\%$ of the testdata, $1 \le D \le 10$, $1 \le n \le 10^4$.
Translated by ChatGPT 5