/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 400 点
問題文
二次元座標平面上に 1\times 1 の正方形が無限に敷き詰められています。
ある正方形の中心を中心として、半径 R の円を描いたとき、円に完全に内包される正方形は何個あるでしょうか?
より厳密には、整数組 (i,j) であって、4 点 (i+0.5,j+0.5),(i+0.5,j-0.5),(i-0.5,j+0.5),(i-0.5,j-0.5) 全てが原点との距離が R 以下という条件を満たすものの個数を求めてください。
制約
- 1\leq R\leq 10^{6}
- 入力される数値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
R
出力
答えを出力せよ。
入力例 1
2
出力例 1
5
正方形の中心が円の中心と一致するような正方形、及びその正方形に隣接する正方形 4 個の、合計 5 個の正方形が円に完全に内包されています。
入力例 2
4
出力例 2
37
入力例 3
26
出力例 3
2025
Score : 400 points
Problem Statement
On the two-dimensional coordinate plane, there is an infinite tiling of 1 \times 1 squares.
Consider drawing a circle of radius R centered at the center of one of these squares. How many of these squares are completely contained inside the circle?
More precisely, find the number of integer pairs (i,j) such that all four points (i+0.5,j+0.5), (i+0.5,j-0.5), (i-0.5,j+0.5), and (i-0.5,j-0.5) are at a distance of at most R from the origin.
Constraints
- 1 \leq R \leq 10^{6}
- All input values are integers.
Input
The input is given from Standard Input in the following format:
R
Output
Print the answer.
Sample Input 1
2
Sample Output 1
5
There are a total of five squares completely contained in the circle: the square whose center matches the circle’s center, plus the four squares adjacent to it.
Sample Input 2
4
Sample Output 2
37
Sample Input 3
26
Sample Output 3
2025