题解 | #矩阵乘法计算量估算#
矩阵乘法计算量估算
https://www.nowcoder.com/practice/15e41630514445719a942e004edc0a5b
while True:
try:
n = int(input())
L = []
stack = []
for i in range(n):
L.append(tuple(map(int, input().split())))
M = input()
i = 0
num = 0
for m in M:
if m.isalpha():
stack.append(L[i])
i += 1
elif m == ")":
b = stack.pop()
a = stack.pop()
num += a[0] * b[0] * b[1]
stack.append((a[0], b[1]))
print(num)
except:
break
查看2道真题和解析