1#include <cstdio>2#include <cstring>3#include <cstdlib>4#include <iostream>5#include <algorithm>6#include <map>7 8 using namespacestd;9 Ten intN; One AMap <Char,Double>ar; - - intMain () { thear['C'] =12.01; -ar['H'] =1.008; -ar['O'] =16.00; -ar['N'] =14.01; + -scanf"%d",&N); + A while(N--){ at Charch[ -]; - -scanf"%s", ch); - intA =strlen (CH); - DoubleAns =0; - in for(inti =0; I < a;++i) { - if(Ch[i] >='A'&& Ch[i] <='Z'){ to intPos = i +1; + Doublesum =0; - BOOLFlag =false; the * while(Ch[pos] >='0'&& Ch[pos] <='9'&& Pos <a) { $sum = SUM *Ten+int(Ch[pos]-'0');Panax NotoginsengPos + +; -Flag =true; the } + A if(!flag) { thesum =1; + } -Ans + = sum *Ar[ch[i]]; $ } $ } -printf"%.3f\n", Ans); - } the - return 0;Wuyi}
View Code
1#include <cstdio>2#include <cstring>3#include <cstdlib>4#include <iostream>5#include <algorithm>6 7 using namespacestd;8 9 intN;Ten One structyes{ A Charch[ -]; -}p[ Max]; - the intMain () { -scanf"%d",&N); - - for(inti =1; I <= n;++i) { +scanf"%s", p[i].ch); - + intA =strlen (p[i].ch); A at for(intj =0; J < a;++j) { -P[i].ch[j + A] =P[i].ch[j]; - } - - stringMin ="zzzzzzzzzzzzzzzz"; - in for(intj =0; J < a;++j) { - intK = j + A-1; to strings; + - for(intg = J;g <= k;++g) thes + =P[i].ch[g]; * //cout << s << endl; $ if(S <min) {Panax NotoginsengMin =s; - //cout << "min::" << min << Endl; the } + } A the for(intj =0; J < Min.length (); + +j) { +cout <<Min[j]; - } $ $printf"\ n"); - } - the return 0; -}
View Code
UVA 1586 Molecular Weight UVA 1584 dictionary order minimum