P4134 [BJOI2012] Lianliankan
Description
Among IQ-test problems there is often an elimination game. But this round of Lianliankan is not the visual-matching game on QQ. Our rule is: given all integers in the closed interval $[a, b]$, if there exist two numbers $x$, $y$ ($x > y$) such that their square difference $x^2 - y^2$ is a perfect square $z^2$, and $y$ and $z$ are coprime, then you may connect $x$ and $y$, remove them together, and gain $x + y$ points. The goal is to maximize the number of removable pairs, and subject to that, maximize the total score. Try to figure it out.
Input Format
One line with two integers, denoting $a$ and $b$.
Output Format
Two integers: the number of pairs that can be removed, and, under that condition, the maximum total score.
Explanation/Hint
Constraints:
- For $30\%$ of the testdata, $1 \le a, b \le 100$.
- For $100\%$ of the testdata, $1 \le a, b \le 1000$.
Translated by ChatGPT 5