CF1823C.Strongly Composite
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A prime number is an integer greater than 1 , which has exactly two divisors. For example, 7 is a prime, since it has two divisors {1,7} . A composite number is an integer greater than 1 , which has more than two different divisors.
Note that the integer 1 is neither prime nor composite.
Let's look at some composite number v . It has several divisors: some divisors are prime, others are composite themselves. If the number of prime divisors of v is less or equal to the number of composite divisors, let's name v as strongly composite.
For example, number 12 has 6 divisors: {1,2,3,4,6,12} , two divisors 2 and 3 are prime, while three divisors 4 , 6 and 12 are composite. So, 12 is strongly composite. Other examples of strongly composite numbers are 4 , 8 , 9 , 16 and so on.
On the other side, divisors of 15 are {1,3,5,15} : 3 and 5 are prime, 15 is composite. So, 15 is not a strongly composite. Other examples are: 2 , 3 , 5 , 6 , 7 , 10 and so on.
You are given n integers a1,a2,…,an ( ai>1 ). You have to build an array b1,b2,…,bk such that following conditions are satisfied:
- Product of all elements of array a is equal to product of all elements of array b : a1⋅a2⋅…⋅an=b1⋅b2⋅…⋅bk ;
- All elements of array b are integers greater than 1 and strongly composite;
- The size k of array b is the maximum possible.
Find the size k of array b , or report, that there is no array b satisfying the conditions.
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t ( 1≤t≤1000 ). The description of the test cases follows.
The first line of each test case contains one integer n ( 1≤n≤1000 ) — the size of the array a .
The second line of each test case contains n integer a1,a2,…an ( 2≤ai≤107 ) — the array a itself.
It is guaranteed that the sum of n over all test cases does not exceed 1000 .
输出格式
For each test case, print the size k of array b , or 0 , if there is no array b satisfying the conditions.
输入输出样例
输入#1
8 2 3 6 3 3 4 5 2 2 3 3 3 10 14 2 25 30 1 1080 9 3 3 3 5 5 5 7 7 7 20 12 15 2 2 2 2 2 3 3 3 17 21 21 21 30 6 6 33 31 39
输出#1
1 1 0 2 2 3 4 15
说明/提示
In the first test case, we can get array b=[18] : a1⋅a2=18=b1 ; 18 is strongly composite number.
In the second test case, we can get array b=[60] : a1⋅a2⋅a3=60=b1 ; 60 is strongly composite number.
In the third test case, there is no array b satisfying the conditions.
In the fourth test case, we can get array b=[4,105] : a1⋅a2⋅a3=420=b1⋅b2 ; 4 and 105 are strongly composite numbers.