#K43257. Subsequence Perfect Square Product
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 , where 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 ), 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 , the number of test cases. Each test case consists of two lines:
1. The first line contains an integer , the number of elements in the array.
2. The second line contains 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>