Relative atomic mass

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 617    Accepted Submission(s):
516

Problem Description
Relative atomic mass is a dimensionless physical
quantity, the ratio of the average mass of atoms of an element (from a single
given sample or source) to 12

of the mass of an atom of carbon-12 (known as the unified atomic mass
unit).
You need to calculate the relative atomic mass of a molecule, which
consists of one or several atoms. In this problem, you only need to process
molecules which contain hydrogen atoms, oxygen atoms, and carbon atoms. These
three types of atom are written as ’H’,’O’ and ’C’ repectively. For your
information, the relative atomic mass of one hydrogen atom is 1, and the
relative atomic mass of one oxygen atom is 16 and the relative atomic mass of
one carbon atom is 12. A molecule is demonstrated as a string, of which each
letter is for an atom. For example, a molecule ’HOH’ contains two hydrogen atoms
and one oxygen atom, therefore its relative atomic mass is 18 = 2 * 1 +
16.

 
Input
The first line of input contains one integer N(N ≤ 10),
the number of molecules. In the next N lines, the i-th line contains a string,
describing the i-th molecule. The length of each string would not exceed
10.
 
Output
For each molecule, output its relative atomic mass.
 
Sample Input
5
H
C
O
HOH
CHHHCHHOH
 
Sample Output
1
12
16
18
46
 
Source
【思路】模拟
【code】
#include<iostream>
#include<cstdio>
using namespace std;
string s;
int ans,n;
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
cin>>s;ans=;
for(int i=;i<s.size();i++)
{
if(s[i]=='C')ans+=;
if(s[i]=='O')ans+=;
if(s[i]=='H')ans++;
}
printf("%d\n",ans);
}
return ;
}

Relative atomic mass的更多相关文章

  1. HDU 5949 Relative atomic mass 【模拟】 (2016ACM/ICPC亚洲区沈阳站)

    Relative atomic mass Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

  2. 【HDOJ5949】Relative atomic mass(签到)

    题意:给定一个只由H.C.O三种分子组成物质的分子式,求相对分子质量 len<=10 思路:队友写的 #include <stdio.h> #include <vector&g ...

  3. 2016ACM/ICPC亚洲区沈阳站-重现赛赛题

    今天做的沈阳站重现赛,自己还是太水,只做出两道签到题,另外两道看懂题意了,但是也没能做出来. 1. Thickest Burger Time Limit: 2000/1000 MS (Java/Oth ...

  4. 2016ACM/ICPC亚洲区沈阳站 - A/B/C/E/G/H/I - (Undone)

    链接:传送门 A - Thickest Burger - [签到水题] ACM ICPC is launching a thick burger. The thickness (or the heig ...

  5. ACM Shenyang Onsite 2016 题目

    A. Thickest Burger 1000ms 262144K   ACM ICPC is launching a thick burger. The thickness (or the heig ...

  6. 2016ACM/ICPC亚洲区沈阳站 Solution

    A - Thickest Burger 水. #include <bits/stdc++.h> using namespace std; int t; int a, b; int main ...

  7. The 2016 ACM-ICPC Asia Shenyang Regional Contest

    A. Thickest Burger 大数 × 2 + 小数 #include <cstdio> #include <algorithm> using namespace st ...

  8. 2016 ACM/ICPC亚洲区沈阳站

    A B C D E F G H I J K L M O O O $\varnothing$ $\varnothing$   $\varnothing$ $\varnothing$ $\varnothi ...

  9. absurd, abundant

    absurd How: absolutely, completely, clearly, faintly, manifestly, obviously, patently, quite, rather ...

随机推荐

  1. TCP三次握手与DDOS攻击原理

    TCP三次握手与DDOS攻击原理 作者:冰盾防火墙 网站:www.bingdun.com 日期:2014-12-09   在TCP/IP协议中,TCP协议提供可靠的连接服务,采用三次握手建立一个连接. ...

  2. opencv yuv420与Mat互转

    项目用到opencv 融合图片的功能,经过一天的调试,达到预期目标,先将如何调用opencv库实现YUV42与Mat互转记录下来. 一.下载opencv编译的库下载地址是:http://opencv. ...

  3. uboot下载地址

    非常奇怪百度搜索都搜不到一个好的uboot下载的说明,仅此标记 HOME http://www.denx.de/wiki/U-Boot/SourceCode sourcecode http://www ...

  4. python-pyDes-ECB加密-DES-DES3加密

    网上的教程都他妹的是抄的,抄也就算了,还改抄错了,害我写了一两天都没找到原因,直接去官网看,找例子很方便 官网链接:http://twhiteman.netfirms.com/des.html 一个小 ...

  5. poj3034--Whac-a-Mole(dp)

    题目链接:id=3034">点击打开链接 题目大意:砸地鼠游戏,n*n的方格,锤子每次最多移动d,地鼠在t时刻出如今(x,y)时间.维持一个单位时间,不会在同一时间同一位置出现两仅仅老 ...

  6. poj3040(双向贪心)

    Allowance Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1540   Accepted: 637 Descript ...

  7. python中的and和or(转载)

    python中的and和or 4.6. and 和 or 的特殊性质在Python 中,and 和 or 执行布尔逻辑演算,如你所期待的一样,但是它们并不返回布尔值:而是,返回它们实际进行比较的值之一 ...

  8. [转]***换机房换ip之后不能连外网

    ***换机房换ip之后不能连外网 时间 2015-07-21 15:17:16  Wendal随笔 原文  http://wendal.net/2015/07/21.html 主题 iptables ...

  9. 基于XML配置的Sping AOP详解

    一.编写基本处理方法 package com.kang.sping.xml.aop; public class Math{ //加 public int add(int n1,int n2){ int ...

  10. 在Win7创建WiFi热点

    1.在开始菜单搜索cmd 2.运行cmd 3.输入以下命令,注意:Your-WiFi-Name和Your-WiFi-Password分别为WiFi名称和密码 netsh wlan set hosted ...