404507: GYM101521 K Lattice Points
Description
Jeremy loves geometry and counting. Unsurprisingly, he wants to do both at the same time!
On a Cartesian coordinate plane, Jeremy now draws a circle of radius R, centered at the origin. He wants to know how many lattice points have a distance no further than D units from the circumference of the circle he has just drawn. A lattice point on the Cartesian coordinate plane is a point with integer coordinates.
Jeremy can only draw small circles and count the points one by one. When R and D get large, he has no idea what the answer is. Help Jeremy!
InputThe first and only line of input consists of two integers R and D.
For all input, 1 ≤ R ≤ 500000, 0 ≤ D ≤ 500000.
OutputOutput one single integer, the number of lattice points no further than D units from the circumference of a circle of radius R and centered at the origin.
Hint: Use 64-bit integers (Pascal: int64, C++: long long).
ExamplesInput3 1Output
40Input
2 4Output
113Input
123456 78901Output
122406524248Note
Pictured is sample 1. The small dots indicate the lattice points that should be counted towards the answer.