#P5438. 【XR-2】记忆
【XR-2】记忆
Description
Your memory was taken away by the Singer.
Before leaving, the Singer told you that there is a sequence in your memory, and this sequence is a permutation of all integers with .
After thinking for a moment, the Singer decided to tell you a bit more:
If we define the weight of a sequence as the number of adjacent pairs whose product is a perfect square, then the sequence in your memory is the permutation with the maximum weight among all permutations formed by the integers with .
The Singer wants you to tell him the weight of the sequence in your memory. Only then will he return your memory to you.
Input Format
One line containing two positive integers .
Output Format
One line containing one integer, which is the answer.
2 10
2
Hint
[Sample Explanation]
One permutation with weight is . In it, and are perfect squares. This is also the permutation with the maximum weight among all permutations formed by the integers with .
[Constraints]
This problem uses bundled tests.
Subtask 1 (3 points): .
Subtask 2 (7 points): .
Subtask 3 (15 points): .
Subtask 4 (11 points): .
Subtask 5 (8 points): .
Subtask 6 (19 points): .
Subtask 7 (37 points): no special restrictions.
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号