LearnPy Hub
← Arena
AdvancedRating 1700

Will the Knight Stay On?

A knight on an n × n board makes k random moves; each move picks one of its 8 moves with equal chance, even ones that leave the board. Once off the board it stops. Print the probability it is still on the board after k moves, rounded to 6 decimal places.

Input

n, k, row and column of the start (rows and columns from 0).

Output

One number.

Sample 1

Input
3 2 0 0
Output
0.062500

Sample 2

Input
1 0 0 0
Output
1.000000
solution.py
Output appears here
Will the Knight Stay On? · Python Arena problem · LearnPy Hub