問題一覧 > 通常問題

No.781 Counting Lattice Points on a Circle

レベル : / AI推定難易度 : 925 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 175
作問者 : startcpp / テスター : はむこ
お気に入りにしたユーザー ProblemId : 1709 / 自分の提出
問題文最終更新日: 2026-06-25 12:46:20
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 204 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。