#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
const int maxn = 105;
char s[105];
int main(){
int t;
cin>>t;
while(t--){
scanf("%s",s);
double M,sum=0.0;
int len=strlen(s);
for(int i=0;i<len;i++){
if(s[i]>='0'&&s[i]<='9')continue;
if(s[i]=='C')
M=12.01;
else if(s[i]=='H')M=1.008;
else if(s[i]=='O')M=16.00;
else if(s[i]=='N')M=14.01;
int p=i+1;
int n;
if(s[p]>='0'&&s[p]<='9'){
n=0;
while(s[p]>='0'&&s[p]<='9'){
n=n*10+s[p]-'0';
p++;
}
}
else
n=1;
sum+=M*n;
}
printf("%.3lf\n",sum);
}
return 0;
}
Molar mass UVA - 1586
最新推荐文章于 2022-12-26 00:23:51 发布