#P1781D. Many Perfect Squares
Many Perfect Squares
Description
You are given a set of distinct positive integers.
We define the squareness of an integer as the number of perfect squares among the numbers .
Find the maximum squareness among all integers between and , inclusive.
Perfect squares are integers of the form , where is a non-negative integer. The smallest perfect squares are .
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer () — the size of the set.
The second line contains distinct integers in increasing order () — the set itself.
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, print a single integer — the largest possible number of perfect squares among , for some .
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer () — the size of the set.
The second line contains distinct integers in increasing order () — the set itself.
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, print a single integer — the largest possible number of perfect squares among , for some .
Note
In the first test case, for the set contains two perfect squares: and . It is impossible to obtain more than two perfect squares.
In the second test case, for the set looks like , that is, all its elements are perfect squares.