The King's Options
A king stands at (R, C) on an N×N board. How many squares can it move to (its 8-neighbourhood clipped to the board)?
Input: one line with three integers N R C.
Output: the number of legal king moves.
Constraints:
- 1 ≤ N ≤ 109
- 1 ≤ R, C ≤ N
Sample Tests
Input 1
8 1 1
Output 1
3
Input 2
8 4 4
Output 2
8
Discussion (opens after you solve — no spoilers before)
No comments yet.