#C8164. Distinct Reachable Positions
Distinct Reachable Positions
Distinct Reachable Positions
You are given an initial coordinate \((x, y)\) and an energy limit \(E\). From the starting position, you can perform a move using one of the nine possible moves:
- \((0, 0)\) (i.e. staying in place)
- \((1, 0)\), \((-1, 0)\), \((0, 1)\), \((0, -1)\)
- \((1, 1)\), \((-1, -1)\), \((1, -1)\), \((-1, 1)\)
Each move consumes one unit of energy. You can make at most \(E\) moves (i.e. steps), and you are allowed to make fewer moves. Determine the number of distinct positions you can reach. It can be shown that the answer is given by the formula:
[ (2E+1)^2 ]
Note that the initial position is counted as a reachable position.
inputFormat
The input consists of a single line containing three space-separated integers: (x), (y) and (E), where (x) and (y) represent the initial coordinates, and (E) represents the energy available.
outputFormat
Output a single integer, the number of distinct positions that can be reached with at most (E) moves from the starting position.## sample
0 0 2
25