Python题解 | #矩阵乘法计算量估算#
矩阵乘法计算量估算
https://www.nowcoder.com/practice/15e41630514445719a942e004edc0a5b
while True: try: n = int(input()) arr = [] for i in range(n): arr.append(list(map(int, input().strip().split(' ')))) s = input() order = [] res = 0 for i in s: if i.isalpha(): order.append(arr[ord(i) - 65]) elif i == ')' and len(order) >= 2: a = order.pop() b = order.pop() res += b[0] * b[1] * a[1] order.append([b[0], a[1]]) print(res) except: break