Yash and Minimum Operations

3

1 votes
Implementaion
Problem

Given an array A which contains N numbers, you can perform magic operations on it.

A magic operation is defined as choosing any element Ai  and multiplying it by any real number R.

The array is called magical if all the array elements are equal. The target is to make the array magical in the minimum number of operations.

Yash, who got a job offer from the prestigious ‘M.net’, asks you to solve this for him.

Note: As mentioned earlier, R is a real number. It does not have to be an integer.

Input Format

First line contains number of test cases T.

Each test case has below input format:

First line contains N, number of elements in the array A.

Second line has n space seperated numbers, Ai.

Output Format

For T test cases:

Single line containing m, minimum number of operations required to make array magical.

Constraints

1 <= <= 10

1 <= <= 105

1 <= Ai <= 109, where i ∈ [0,n)

∈ Real Number

Sample Input
1
4
1 2 5 10
Sample Output
3
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

1st Operation - Select 1 and multiply by 10 

2nd Operation - Select 2 and multiply by 5

3rd Operation - Select 5 and multiply by 2

All array elements now equal to 10, so minimum 3 operations required.

Contributers:
Editor Image

?