题解 | #矩阵乘法计算量估算#

矩阵乘法计算量估算

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

def calmul(a,b,c,d):
    return a*b*d
num = int(input())
matrixs = []
for i in range(num):
    matrixs.append(input().split())
commands = input()
order = []
res = 0
for command in commands:
    if command != ')':
        if command == '(':
            order.append(command)
        else:
            order.append(matrixs[ord(command)-ord('A')])
    else:
        a = order.pop()
        b = order.pop()
        order.pop()
        order.append([b[0],a[1]])
        res = res + calmul(int(b[0]),int(b[1]),int(a[0]),int(a[1]))
print(res)

全部评论

相关推荐

ResourceUtilization:你是我见过最美的牛客女孩
点赞 评论 收藏
分享
白火同学:能。我当初应届沟通了1200,收简历50,面试10左右吧,加油投吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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