P1002 #1RE #3#4WA #5RE
查看原帖
P1002 #1RE #3#4WA #5RE
1418961
DriftingDreams楼主2024/8/9 18:27

求救,哪位大佬可以帮忙检查以下我的代码,使用Python,自行调试没有问题。

width, height, x, y = map(int, input().split())
map = []
map.append([1 for _ in range(width + 1)])
for i in range(1, height + 1):
    map.append([1])
    for j in range(1, width + 1):
        map[i].append(-1)
map[0][0] = float("inf")
map[width][height] = -1

map[x][y] = 0
for i in range(len(map)):
    for j in range(len(map[0])):
        if not ((i == 0 and j == 0) and (i == len(map) and j == len(map[0]))):
            if ((i - x)**2 + (j - y)**2) == 5:
                map[i][j] = 0

for i in range(1, len(map)):
    for j in range(1, len(map[0])):
        if map[i][j] != 0:
            map[i][j] = map[i - 1][j] + map[i][j - 1]

print(map[width][height])
2024/8/9 18:27
加载中...