AT_abc413_d [ABC413D] Make Geometric Sequence
Description
You are given an integer sequence $ A=(A_1,A_2,\ldots,A_N) $ of length $ N $ . It is guaranteed that for any $ i\ (1\le i\le N) $ , $ A_i $ is not $ 0 $ .
Determine whether there exists a permutation $ B=(B_1,B_2,\ldots,B_N) $ of $ A $ such that $ B $ forms a geometric sequence.
A sequence $ S=(S_1,S_2,\ldots,S_N) $ is a geometric sequence if there exists a real number $ r $ such that $ S_{i+1}=rS_i $ for all integers $ 1\le i\lt N $ .
Solve $ T $ test cases per input file.
Input Format
The input is given from standard input in the following format:
> $ T $ $ \mathrm{testcase}_1 $ $ \mathrm{testcase}_2 $ $ \vdots $ $ \mathrm{testcase}_T $
where $ \mathrm{testcase}_i $ is the $ i $ -th test case $ (1\le i\le T) $ , and each test case is given in the following format:
> $ N $ $ A_1 $ $ A_2 $ $ \ldots $ $ A_N $
Output Format
Output $ T $ lines. The $ i $ -th line $ (1\le i\le T) $ should contain `Yes` if $ A $ can be rearranged to form a geometric sequence in the $ i $ -th test case, and `No` otherwise.
Explanation/Hint
### Sample Explanation 1
In the first test case, the rearrangement $ (16,8,4,2,1) $ of $ A $ forms a geometric sequence with common ratio $ r=\frac{1}{2} $ . Thus, print `Yes` on the first line.
In the second test case, no rearrangement of $ A $ satisfies the condition. Thus, print `No` on the second line.
### Constraints
- $ 1\le T\le10^5 $
- $ 2\le N\le2\times10^5 $
- $ -10^9\le A_i\le10^9\ (1\le i\le N) $
- $ A_i\ne0\ (1\le i\le N) $
- The sum of $ N $ over all test cases in a single input file is at most $ 2\times10^5 $ .
- All input values are integers.