cin.fail();格式错误,未读取到预期参数值类型;指针不变,设置流状态为failbit;
cin.bad();输入发生毁灭性错误,导致io不稳定
cin.eof();遇到文件终止符
cin.good();
cin.get(char c);
cin.get(char c,int ,终止字符);
cin.getline(char *,int ,终止字符);
cin.ignore(int,终止字符)
char cin.peek() ;返回输入流下一个字符,流指针不变;
cin.putback(char c);将前面用cin读取到的单个字符,返回输入流中;
//#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <queue>
#include <vector>
#include <iterator>
#include <map>
#include <bitset>
#include <stack>
#include <deque>
#include <cmath>
#include <iomanip>
#include <forward_list>
#include <set>
#include <cmath>
#include <cctype>
#include <sstream>
#include <climits>
#include <list>
#include <typeinfo>
//INT_MAX 32 bit int
//LLONG_MAX 64 bit int
//LONG_MAX 64 bit int
using namespace std;
//#pragma comment(linker, "/STACK:3073741824")
#define memmin(a) memset(a,0,sizeof(a))
#define memmax(a) memset(a,0x3f,sizeof(a));
#define spr(n) fixed << setprecision(n)
#define endll '\n'
#define ifor(i, l, r) for (long long (i) = (l); (i) <= (r); ++(i))
#define rfor(i, r, l) for (long long (i) = (r); (i) >= (l); --(i))
#define fori(i,l,r) for(auto i=p;i!=p1;++i)
#define rfori(i,rl,rr) for(auto i=rl;i!=rr;++i)
#define coute cout<<'\n'
typedef long long ll;
typedef pair<int, int> P;
typedef unsigned long long ull;
template <class T, class Container = vector<T>,
class Compare = less<typename Container::value_type> >
using priqueue = priority_queue<T,Container,Compare>;
#define start1
#ifndef start1
const int IINF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1.0e-9;
const long long MOD = 1e9 + 7;
const int MAX1 = 1e5 + 100;
const int MAX2 = 1e7 + 100;
#endif
#define start2
#ifndef start2
//__int128读取
void read(ll& w) {
w=0;
ll f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch <= '9' && ch >= '0') {
w = w * 10 + ch - '0';
ch = getchar();
}
}
void print128(ll x) {
if (x < 0) {
putchar('-');
x = -x;
}
if (x > 9)print128(x / 10);
putchar(x % 10 + '0');
}
#endif
#define start
#ifndef start3
template<typename container>
void _print(container &a2) {
for (auto i = a2.begin(); i != a2.end(); i++) {
if (i == a2.begin()) cout << *i;
else
cout << " " << *i;
}
}
template<typename T1>
auto _print(T1 a1, ll l, ll r) ->void {
for (ll i = l; i <= r; ++i) {
if (i == l) cout << a1[i];
else cout << " " << a1[i];
}
}
#endif
map<char,double>das;
int main(int argv,char** argc) {
// ios::sync_with_stdio(false);
// cin.tie(0);
// cout.tie(0);
das['C']=12.01,das['H']=1.008,das['O']=16.00,das['N']=14.01;
int t;
cin>>t;
getchar();
while(t--) {
double sum{};
char c;
while(cin.get(c)&&c!='\n') {
// cout<<c<<endl;
if(isdigit(cin.peek())) {
int x;
cin>>x;
sum+=x*das[c];
}else{
sum+=das[c];
}
}
cout<<spr(3)<<sum<<endl;
}
return 0;
}