CF2103A.Common Multiple

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Common Multiple

You are given an array of integers a1,a2,,ana_1, a_2, \ldots, a_n. An array x1,x2,,xmx_1, x_2, \ldots, x_m is beautiful if there exists an array y1,y2,,ymy_1, y_2, \ldots, y_m such that the elements of yy are distinct (in other words, yiyjy_i\neq y_j for all 1i<jm1 \le i \lt j \le m), and the product of xix_i and yiy_i is the same for all 1im1 \le i \le m (in other words, xiyi=xjyjx_i\cdot y_i = x_j\cdot y_j for all 1i<jm1 \le i \lt j \le m).

Your task is to determine the maximum size of a subsequence^{\text{∗}} of array aa that is beautiful.

^{\text{∗}}A sequence bb is a subsequence of a sequence aa if bb can be obtained from aa by the deletion of several (possibly, zero or all) element from arbitrary positions.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t5001 \le t \le 500). The description of the test cases follows.

The first line of each test case contains a single integer nn (1n1001 \le n \le 100) — the length of the array aa.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ain1 \le a_i \le n) — the elements of array aa.

Note that there are no constraints on the sum of nn over all test cases.

Output

For each test case, output the maximum size of a subsequence of array aa that is beautiful.

Note

In the first test case, the entire array a=[1,2,3]a = [1, 2, 3] is already beautiful. A possible array yy is [6,3,2][6, 3, 2], which is valid since the elements of yy are distinct, and 16=23=321\cdot 6 = 2\cdot 3 = 3\cdot 2.

In the second test case, the subsequence [3,1,4,5][3, 1, 4, 5] is beautiful. A possible array yy is [20,60,15,12][20, 60, 15, 12]. It can be proven that the entire array a=[3,1,4,1,5]a = [3, 1, 4, 1, 5] is not beautiful, so the maximum size of a subsequence of array aa that is beautiful is 44.

Samples

3
3
1 2 3
5
3 1 4 1 5
1
1
3
4
1

在线编程 IDE

建议全屏模式获得最佳体验