#P5881. 【化学】实验
【化学】实验
Description
In front of her, there are test tubes. Each test tube contains an unknown liquid. For each kind of unknown liquid, there are known chemical attributes: and . The two attribute values of the -th liquid are and .
Now, the teacher assigns her experiments.
For each experiment, there is a reference value (the reference value of the -th experiment is denoted as ). She needs to divide the unknown liquids into as many groups as possible, such that: for any two liquids and in different groups, must not be greater than .
Here, denotes the greatest common square divisor. is a common square divisor of two numbers if and only if it satisfies both of the following:
- is a common divisor of the two numbers;
- is a perfect square.
The greatest common square divisor is the maximum among all that satisfy the conditions.
Intuitively, can be understood as: take the greatest common divisor of the two numbers, take its square root, keep only the integer factor part, and then square it back.
For example:
To compute , first compute the greatest common divisor of and , which is . Then . Its integer factor is , so .
She also needs, under the condition that the number of groups is maximized, to maximize her experiment score.
Definition of the experiment score: for each reagent, define its score as the largest exponent in the prime factorization of .
For example: , so .
, so .
The experiment score is the sum, over all groups, of the maximum within each group.
Of course, her is not very high, so she needs to ask for your help.
Input Format
The first line contains two integers .
The second line contains integers .
The third line contains integers .
The fourth line contains integers .
Output Format
Output lines. For the -th line, output integers: the number of groups and the experiment score for the -th experiment.
5 5
36 72 4 9 16
2 4 6 8 10
2 3 4 5 6
3 5
4 7
4 7
4 7
5 8
Hint
Sample Explanation #1
.
.
.
.
.
When , it can be divided into three groups: .
The experiment score is .
Constraints
"This problem uses bundled testdata."
| subtask | Score | |||||
|---|---|---|---|---|---|---|
For of the data:
, , , .
I... I think I made a mistake again... Can I try one more time?
Translated by ChatGPT 5
京公网安备 11011102002149号