python求助!60分
查看原帖
python求助!60分
1263984
llly_ya楼主2024/3/6 13:34
stop=[]#记录马的控制坐标
Bx,By,Mx,My=map(int,input().split())
result=[[1 for i in range(By+1)]for j in range(Bx+1)]
stop.append([Mx,My])
stop.append([Mx-2,My-1])
stop.append([Mx-2,My+1])
stop.append([Mx-1,My-2])
stop.append([Mx-1,My+2])
stop.append([Mx+1,My-2])
stop.append([Mx+1,My+2])
stop.append([Mx+2,My-1])
stop.append([Mx+2,My+1])
for i in range(1,Bx+1):
    for j in range(1,By+1):
        m=0
        n=0
        if [i,j] not in stop:
            if [i-1,j] not in stop:m=result[i-1][j]
            if [i,j-1] not in stop:n=result[i][j-1]
            result[i][j]=m+n
        else:result[i][j]=0
print(result[Bx][By])
2024/3/6 13:34
加载中...