UVA-1586 Molar Mass - ACM/ICPC Seoul 2007
2017-10-15 21:36
369 查看
倒着找更好找一些
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int main() { int T;cin>>T; while(T--){ double sum=0.0,m=1.0;int k=1; char s[100];cin>>s;int num=strlen(s); for(int i=num-1;i>=0;i--){ if(s[i]>='0'&&s[i]<='9'){ if(k==1) m=0; m+=k*(s[i]-'0'); k*=10; }//if else { k=1;double c; if(s[i]=='C') c=12.010; else if(s[i]=='H') c=1.008; else if(s[i]=='O') c=16.000; else c=14.010; sum+=m*c; m=1.0; } }//for printf("%.3lf\n",sum);//格式,lf不是llf }//while return 0; }
相关文章推荐
- 分子量(Molar Mass, ACM/ICPC Seoul 2007, UVa1586)
- Molar Mass, ACM/ICPC Seoul 2007,Uva1586 给出一种物质的分子式,求分子量
- b2bf 分子量(Molar Mass, ACM/ICPC Seoul 2007, UVa1586)
- Molar Mass, ACM/ICPC Seoul 2007, UVa 1586
- 算法竞赛入门经典-习题3-2 分子量(Molar Mass, ACM/ICPC Seoul 2007, UVa1586)
- 分子量 (Molar Mass,ACM/ICPC Seoul 2007,UVa 1586)
- 算法竞赛入门竞赛 习题3-2 分子量(Molar Mass, ACM/ICPC Seoul 2007, UVa1586)
- 习题3-2 分子量(Molar Mass, ACM/ICPC Seoul 2007, UVa1586)
- UVa 1586 - Molar Mass - ACM/ICPC Seoul 2007 - C语言
- [Molar Mass, ACM/ICPC Seoul 2007, UVA1586]
- 分子量 (Molar Mass, ACM/ICPC Seoul 2007, UVa1586)
- 习题 3-2 分子量 (ACM/ICPC Seoul 2007, UVa1586)
- 分子量-Molar Mass,ACM/ICPC Seoul 2007,UVa1586
- 数数字 (Digit Counting, ACM/ICPC Danang 2007, UVa1225)
- Digit Generator, ACM/ICPC Seoul 2005, UVa1583
- 数数字(Digit Counting,ACM/ICPC Danang 2007,UVa1225)
- 数数字-Digit Counting,ACM/ICPC Danang 2007,UVa122
- 习题3-3 数数字(Digit Counting , ACM/ICPC Danang 2007, UVa1225)
- 例题8-2 联合国大楼(Building for UN, ACM/ICPC NEERC 2007, UVa1605)
- 3-7 DNA序列(DNA Consensus String, ACM/ICPC Seoul 2006, UVa1368)