题解 | #矩阵乘法计算量估算#一个括号里不能有三个矩阵

矩阵乘法计算量估算

http://www.nowcoder.com/practice/15e41630514445719a942e004edc0a5b

while True:

try:
    
    n = int(input())
    matrix_list = []
    for i in range(n):
        matrix_list.append([int(i) for i in input().split()])
        
    rule = input()
    
    temp = []
    times = 0
    for i in rule:
        if i.isalpha():
            temp.append(i)
        elif i == ')':
            x = temp.pop()
            y = temp.pop()
            times += matrix_list[ord(y)-65][0] * matrix_list[ord(y)-65][1] * matrix_list[ord(x)-65][1]
            
            matrix_list[ord(y)-65] = (matrix_list[ord(y)-65][0], matrix_list[ord(x)-65][1])
            temp.append(y)
    print(times)
    
except:
    break
全部评论
请教一下,为什么一个括号里不能有3个矩阵呢?
点赞 回复 分享
发布于 2022-03-05 06:33

相关推荐

uu们,拒offer时hr很生气怎么办我哭死
爱睡觉的冰箱哥:人家回收你的offer,或者oc后没给你发offer的时候可不会愧疚你,所以你拒了也没必要愧疚他。
点赞 评论 收藏
分享
让资本家给我当牛做马:26的秋招还没开始啊?你找的是实习?实习的话你马上就研三了为什么还要实习?
点赞 评论 收藏
分享
05-29 09:02
门头沟学院 Java
点赞 评论 收藏
分享
评论
2
3
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务