#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5;
char a[maxn+100];
ll sum,num,cnt,ans;
int main(){
scanf("%s",(a+1));
int len=strlen(a+1);
for(int i=1;i<=len;){
if(a[i]=='H'||a[i]=='O'||a[i]=='C'){
if(a[i]=='H') num=1;
if(a[i]=='O') num=17;
if(a[i]=='C') num=13;
i++;
while(i<=len&&a[i]>='0'&&a[i]<='9'){
cnt*=10;cnt+=a[i]-'0';i++;
}
if(!cnt) ans+=num,num=0;
else ans+=num*cnt,num=0,cnt=0;
}
else if(a[i]=='('){
sum+=ans;
ans=0;
i++;
}
else if(a[i]==')'){
i++;
while(i<=len&&a[i]>='0'&&a[i]<='9'){
cnt*=10;cnt+=a[i]-'0';i++;
}
if(!cnt) sum+=ans,ans=0;
else sum+=ans*cnt,ans=0,cnt=0;
}
}
sum+=ans;
printf("%lld\n",sum);
return 0;
}
B 分子
最新推荐文章于 2022-06-08 19:27:13 发布