UVA - 442
来源:互联网 发布:点播软件哪家好 编辑:程序博客网 时间:2024/04/29 23:35
//stack处理公式串#include<iostream>#include<cstdio>#include<sstream>#include<cmath>#include<cstring>#include<cctype>#include<algorithm>#include<vector>#include<set>#include<map>#include<queue>#include<deque>#include<stack>using namespace std;const int maxn=30;struct nod{ long long a,b;}p[maxn];nod mk(int x,int y){ nod n; n.a=x,n.b=y; return n;}stack<nod> stk;void init(){ while(!stk.empty()) stk.pop();}int main(){ int T; cin>>T; char chr; string s; while(T--){ cin>>chr; cin>>p[chr-'A'].a>>p[chr-'A'].b; } getchar(); while(getline(cin,s)){ init(); long long ans=0; int jud=0; for(int i=0;i<s.size();i++){ if(isalpha(s[i])) stk.push(p[s[i]-'A']); if(s[i]==')'){ nod n1=stk.top();stk.pop(); nod n2=stk.top();stk.pop(); if(n1.a!=n2.b){ jud=1; cout<<"error"<<endl; break; } else{ stk.push(mk(n2.a,n1.b)); ans+=n2.a*n2.b*n1.b; } } } if(!jud) cout<<ans<<endl; } return 0;}
0 0
- uva 442
- UVA 442
- uva 442
- uva 442
- uva 442
- uva 442
- UVA - 442
- UVA 442
- UVA 442
- UVA 442
- uva oj 442
- uva 442(线性表)
- uva
- UVA
- UVA
- UVA
- uva
- UVA
- 1193
- zend studio集成xDebug
- runtime详解
- 进制转换的原理
- [华为OJ--C++]060-自守数
- UVA - 442
- Guava基础知识
- 自己动手系列——实现一个简单的LinkedLis
- 第一行代码笔记 RecycleView使用
- jsp有哪些动作
- windows下的selenium + python 环境搭建
- hdu2065(指数型母函数+枚举找规律)
- Redis
- Linux信号产生与处理机制学习笔记(一)