Elliptic Arena
Limits: 1 sec., 512 MiB
This statement was translated automatically from Ukrainian.
Splinter wants to set up a training arena in the shape of an ellipse for the Teenage Mutant Ninja Turtles. According to his plan, the floor of the arena needs to be paved with square tiles.
Splinter asked Donatello to estimate how long it will take the four turtles to set up the arena.
Donatello thought that to do this, he first needs to find the answer to the following problem.
For given integers \(n\) and \(m\), you need to find the number of pairs of integers \((i, j)\) satisfying the condition \[\frac{i^2}{n^2}+\frac{j^2}{m^2} \le 1.\]
Then Donatello will use this answer for further calculations, which he will perform on his own.
He only asks you to calculate the answer to the problem.
Input
The first line contains two integers \(n\) and \(m\).
Output
Print a single integer — the answer to Donatello’s problem.
Constraints
\(1 \le n, m \le 10^9\),
\(n \cdot m \le 10^{12}\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 5 5 | 81 |
| Input (stdin) | Output (stdout) |
|---|---|
| 4 3 | 35 |
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|