大佬们,为什么自己运行的时候答案是对的,提交就全错了
  • 板块P1464 Function
  • 楼主bayunzibba
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/12/4 20:26
  • 上次更新2024/12/4 22:34:33
查看原帖
大佬们,为什么自己运行的时候答案是对的,提交就全错了
1576861
bayunzibba楼主2024/12/4 20:26
l = [[[0 for k in range(22)] for j in range(22)] for i in range(22)]


def w(a,b,c):
    if a <= 0 or b <= 0 or c <= 0:
        return 1
    if a > 20 or b > 20 or c > 20:
        return w(20,20,20)
    if l[a][b][c] != 0:
        return l[a][b][c]
    if a < b and b < c:
        l[a][b][c] = w(a,b,c-1) + w(a,b-1,c-1) - w(a,b-1,c)
    else:
        l[a][b][c] = w(a-1,b,c) + w(a-1,b-1,c) + w(a-1,b,c-1) - w(a-1,b-1,c-1)
    return l[a][b][c]


num = []
while True:
    a,b,c = map(int,input().split())
    if a == -1 and b == -1 and c == -1:
        break
    else:
        num.append((a,b,c))

for i in num:
    print(f'w({i[0]},{i[1]},{i[2]}) = {w(i[0],i[1],i[2])}')

2024/12/4 20:26
加载中...