题解 | 栈#矩阵乘法计算量估算#
矩阵乘法计算量估算
http://www.nowcoder.com/practice/15e41630514445719a942e004edc0a5b
while True:
try:
n =int(input())
dic = {}
stk = []
num = 0
for i in range(n):
key = chr(ord('A')+i)
dic[key] = list(map(int,input().split()))
x = input()
for i in range(len(x)):
if x[i] != ')':
stk.append(x[i])
else:
C,B = stk.pop(),stk.pop()
stk.pop()
num += dic[B][0]*dic[B][1]*dic[C][1]
dic[B] = [dic[B][0], dic[C][1]]
stk.append(B)
print(num)
except:
break