409039: GYM103426 C Equation

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Equationtime limit per test2.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

Azat wondered how many pairs of integer roots $$$(x_1, x_2)$$$ of the quadratic equation $$$x^2 + bx + c = 0$$$ exist, when the sum of coefficients $$$b$$$ and $$$c$$$ is between $$$l$$$ and $$$r$$$, that is, $$$l \le b + c \le r$$$ ($$$b$$$, $$$c$$$, $$$l$$$, $$$r$$$ are all integers). Pairs of roots $$$(x_1, x_2)$$$ and $$$(x_2, x_1)$$$ are considered the same.

Help Azat find out the answer to his problem.

Input

The first line contains two integers $$$l$$$ and $$$r$$$ ($$$-10^{12} \le l \le r \le 10^{12}$$$; $$$r - l \le 10^6$$$).

Output

Print a single number — the number of pairs of integer roots, if there are an infinite number of pairs of integer roots, print -1.

Scoring
SubtaskScoreConstraints
$$$1$$$$$$8$$$$$$l = r$$$ and $$$|l| \le 10^3$$$
$$$2$$$$$$9$$$$$$r - l \le 2 \cdot 10^3$$$ and $$$|l|, |r| \le 10^3$$$
$$$3$$$$$$13$$$$$$l = r$$$ and $$$|l| \le 10^6$$$
$$$4$$$$$$20$$$$$$r - l \le 2 \cdot 10^2$$$ and $$$|l|, |r| \le 10^{8}$$$
$$$5$$$$$$16$$$$$$l = r$$$ and $$$|l| \le 10^{12}$$$
$$$6$$$$$$34$$$$$$r - l \le 10^6$$$ and $$$|l|, |r| \le 10^{12}$$$
ExamplesInput
7 7
Output
4
Input
-2 -2
Output
1
Input
-7 -3
Output
13
Note

For $$$l = r = 7$$$, there are four pairs of roots: $$$(2, 9), (0, -7), (3, 5), (-1, -3)$$$.

For the 2 and 9 pair, the equation is $$$x^2 - 11 \cdot x + 18 = 0$$$.

For the 0 and -7 pair, the equation is $$$x^2 + 7 \cdot x + 0 = 0$$$.

For the 3 and 5 pair, the equation is $$$x^2 - 8 \cdot x + 15 = 0$$$.

For the $$$-1$$$ and $$$-3$$$ pair, the equation is $$$x^2 + 4 \cdot x + 3 = 0$$$.

In all four cases, the sum of $$$b$$$ and $$$c$$$ is equal to $$$7$$$.

加入题单

算法标签: