P2651 Add Parentheses III

Description

You are given an expression of the form $a_{1}/a_{2}/a_{3}/.../a_{n}$. If you evaluate it directly from left to right, for example, $1/2/1/4 = 1/8$. However, Little A feels uncomfortable seeing a fraction and wants to insert some parentheses to make it an integer. One possible way is $(1/2)/(1/4)=2$. Given the expression, determine whether it is possible to change the evaluation order by adding parentheses so that the result becomes an integer.

Input Format

There are multiple expressions in one test file. The first line contains $t$, the number of expressions. For each expression, the first line contains $n$, and the second line contains $n$ numbers. The $i$-th number denotes $a_{i}$.

Output Format

Output $t$ lines. For each expression, if it is possible to change the evaluation order by adding parentheses to make the result an integer, output `Yes`; otherwise, output `No`.

Explanation/Hint

- For $40\%$ of the testdata, $n \le 16$. - For $70\%$ of the testdata, $n \le 100$. - For $100\%$ of the testdata, $2 \le n \le 10000$, $1 \le t \le 100$, $1 \le a_{i}\le 2^{31}-1$. Translated by ChatGPT 5