Problem Statement | |||||||||||||
A bishop is a chess piece that can move any number of squares in any diagonal direction (see diagram below).
The chess board has dimensions xSize * ySize, where the top-left corner of the board has coordinates (0, 0), and the bottom-right corner has coordinates (xSize - 1, ySize -1). The bishop is initially at coordinates (x, y). Find the total number of squares reachable by this bishop in k or less moves. Note, that initial square is always counted as reachable. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
| - | xSize will be between 2 and 50000, inclusive. | ||||||||||||
| - | ySize will be between 2 and 50000, inclusive. | ||||||||||||
| - | x will be between 0 and xSize - 1, inclusive. | ||||||||||||
| - | y will be between 0 and ySize - 1, inclusive. | ||||||||||||
| - | k will be between 1 and 50000, inclusive. | ||||||||||||
Examples | |||||||||||||
| 0) | |||||||||||||
| |||||||||||||
| 1) | |||||||||||||
| |||||||||||||
| 2) | |||||||||||||
| |||||||||||||
| 3) | |||||||||||||
| |||||||||||||
| 4) | |||||||||||||
| |||||||||||||