An array of integers is called good if all its elements are perfect squares.
You are given an array
ofintegers. In one move, you can do the following:
- Pick a subset of indices of the array, say
Find the minimum number of moves required to make the array good.
Note: The value of
is fixed for a given move, but can vary between moves.
Input Format
- The first line of input contains an integer
- .
Output Format
For each testcase, output in a single line the minimum number of moves required to make the array good.
Constraints
- .
Subtasks
Subtask #1 (100 points): Original constraints
Sample Input 1
5
3
15 2 4
4
15 14 4 9
3
10 3 6
2
4 9
2
2 8
Sample Output 1
2
2
3
0
1
Explanation
Test case
: One possible sequence of moves is:
- Multiply the first element by
The array is now
, which is good.
Test case
: One possible sequence of moves is:
- Multiply the first and third elements by
The array is now
, which is good.
Test case
: The array is already good, since , so no moves need to be made.
ConversionConversion EmoticonEmoticon