No.131 Manhattan Distance
問題文最終更新日: 2026-06-26 16:15:19
English (AI translation)
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 78
(順位表)
の他の問題:
Problem Statement
The Manhattan distance between a point $(x_1,y_1)$ and a point $(x_2,y_2)$ is expressed as $|\,x_1-x_2|+|\,y_1-y_2|$.
Find how many lattice points at Manhattan distance $d$ from $(0,0)$ lie within the rectangle enclosed by the 4 points $(0,0), (x,0), (0,y), (x,y)$.
Input
$x\ \ \ y\ \ \ d$
All inputs are given as integers.
$1 \le x,y \le 10^9$
$0 \le d \le 2 \times 10^9$
Output
Output the number of lattice points within the range whose Manhattan distance from $(0,0)$ is $d$.
Sample
Sample 1
Input
1 1 1
Output
2
There are 2 such points: $(1,0)$ and $(0,1)$.
Sample 2
Input
1 1 0
Output
1
There is 1 such point: $(0,0$).
Sample 3
Input
1 1 5
Output
0
There are none within the range.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。