#P5949. [BalticOI 2000] Division expression

    ID: 6711 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 显示难度普及− 上传者: 标签>2000BalticOI(波罗的海)

[BalticOI 2000] Division expression

Problem Description

A division expression has the following form:

X1/X2/X3.../XnX_1/X_2/X_3.../X_n, where XiX_i are positive integers and Xi109X_i \le 10^9. The division expression should be evaluated from left to right.

For example, the value of the expression 1/2/1/21/2/1/2 is 1/41/4.

However, you can add parentheses to the expression to change the order of evaluation. For example, the value of (1/2)/(1/2)(1/2)/(1/2) is 11. Now you are given a division expression EE. Determine whether it is possible to make its result an integer by adding parentheses.

Input Format

The first line contains an integer DD, meaning there are DD test cases.

For each test case, a number NN is given first, meaning this test case contains NN numbers.

Then the next line contains NN 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 100%100\% of the testdata, 1D101 \le D \le 10, 1n1041 \le n \le 10^4.

Translated by ChatGPT 5