#K43257. Subsequence Perfect Square Product

    ID: 27269 Type: Default 1000ms 256MiB

Subsequence Perfect Square Product

Subsequence Perfect Square Product

Given an array of integers, determine if there exists a subsequence whose product is a perfect square. A number is a perfect square if it can be expressed in the form n2n^2, where nn is an integer.

The subsequence may consist of one or more elements selected from the array (they do not need to be consecutive), and the product of the selected elements must be a perfect square. Note that the product of an empty subsequence is not considered.

For example, in the array [2, 3, 4, 6], the product of all elements is 144, which is a perfect square (since 122=14412^2 = 144), so the output is "Yes". However, in the array [1, 2, 3, 4, 5], no subsequence's product results in a perfect square, so the output is "No".

inputFormat

The input is given via standard input (stdin).

The first line contains an integer TT, the number of test cases. Each test case consists of two lines:
1. The first line contains an integer nn, the number of elements in the array.
2. The second line contains nn space-separated integers representing the array elements.

outputFormat

For each test case, output a single line: "Yes" if there exists a subsequence whose product is a perfect square, or "No" otherwise.## sample

3
4
2 3 4 6
5
1 2 3 4 5
3
7 11 13
Yes

No No

</p>