http://www.pipioj.online/problem.php?id=1026
1 #define IO std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); 2 #define bug(x) cout<<#x<<" is "<<x<<endl 3 #include <bits/stdc++.h> 4 #define iter ::iterator 5 using namespace std; 6 typedef long long ll; 7 typedef pair<int,ll>P; 8 #define pb push_back 9 #define mk make_pair 10 #define se second 11 #define fi first 12 #define rs o*2+1 13 #define ls o*2 14 const ll mod=1e9+7; 15 const int N=1e2+5; 16 int T,n,m,k; 17 18 string s[N]; 19 20 map<string,int>mp; 21 22 void gao(){ 23 mp["zero"]=0; 24 mp["one"]=1; 25 mp["two"]=2; 26 mp["three"]=3; 27 mp["four"]=4; 28 mp["five"]=5; 29 mp["six"]=6; 30 mp["seven"]=7; 31 mp["eight"]=8; 32 mp["nine"]=9; 33 } 34 35 36 int main(){ 37 IO; 38 gao(); 39 while(cin>>s[1]){ 40 int f1=0,f2=0; 41 42 cin>>s[2]; 43 if(s[2]!="+"){ 44 f1=1; 45 cin>>s[3]>>s[4]>>s[5]; 46 if(s[5]!="=")f2=1,cin>>s[6]; 47 } 48 else{ 49 cin>>s[3]>>s[4]; 50 if(s[4]!="=")f2=1,cin>>s[5]; 51 52 } 53 if(!f1&&!f2&&s[1]=="zero"&&s[3]=="zero")return 0; 54 int x=0,y=0; 55 if(f1)x=mp[s[1]]*10+mp[s[2]]; 56 else x=mp[s[1]]; 57 58 //printf("%d %d ",f1,f2); 59 60 if(f1){ 61 if(f2)y=mp[s[4]]*10+mp[s[5]]; 62 else y=mp[s[4]]; 63 } 64 else{ 65 if(f2)y=mp[s[3]]*10+mp[s[4]]; 66 else y=mp[s[3]]; 67 } 68 cout<<x+y<<endl; 69 } 70 71 72 }