No.781 Counting Lattice Points on a Circle
Problem Statement
For a circle of radius $\sqrt R$ centered at the origin $O$ on the $xy$-plane, let $f(R)$ be the number of lattice points on its circumference.
A lattice point is a point whose $x$-coordinate and $y$-coordinate are both integers.
For example, $f(1) = 4, f(5) = 8, f(25) = 12$.
Given the minimum value $X$ and the maximum value $Y$ of $R$, find $max(f(X), f(X+1), …, f(Y))$. If $X=Y$, find $f(X)$.
Input
X Y
$X$ and $Y$ are integers.
$1 \le X \le Y \le 10^7$
Output
Output the maximum value among $f(X)$~$f(Y)$. Only f(integer) is considered.
Print a newline at the end.
Sample
Sample 1
Input
25 25
Output
12
The positive square root of $25$ is $5$.
There are $12$ lattice points on the circumference of the circle of radius $5$ (centered at the origin).
Therefore, $f(25) = 12$.
Sample 2
Input
1 50000
Output
64
The maximum value among $f(1)~f(50000)$ is $f(27625) = 64$.
Sample 2
Input
33455 37510
Output
48
The maximum value among $f(33455)~f(37510)$ is $f(34450) = 48$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
startcpp
はむこ