Loading Similar Posts
Question 1 Fun Day
from collections import deque
n=int(input())
x,y=list(map(int,input().split()))
k=int(input())
n-=1
q=deque()
q.append((x-1,y-1,k))
won=lost=0
while q:
x,y,k=q.popleft()
if 0<=x<=n and 0<=y<=n:
if k==0:
won+=1
else:
q.append((x-1,y,k-1))
q.append((x,y-1,k-1))
q.append((x+1,y,k-1))
q.append((x,y+1,k-1))
else:
lost+=1
print(won/(won+lost))