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. log4net报错Could not load type 'System.Security.Claims.ClaimsIdentity'

    使用log4net,在win7上可以正常使用,但是在部分xp电脑上可以生成access数据库,但是无法写数据到mdb 排除了程序原因,怀疑是xp缺少什么dll之类的 偶然查到log4net的调试方法: ...

  2. UVA - 1416 Warfare And Logistics (最短路)

    Description The army of United Nations launched a new wave of air strikes on terroristforces. The ob ...

  3. jsp中获取spring 管理的bean(通过config)

    WebApplicationContext wac = (WebApplicationContext)config.getServletContext().getAttribute(WebApplic ...

  4. vue-router钩子beforeRouteEnter函数获取到this实例

    官方文档: const Foo = { template: `...`, beforeRouteEnter (to, from, next) { // 在渲染该组件的对应路由被 confirm 前调用 ...

  5. Win8 使用经验之飞鸽传书

    参考资料: http://jingyan.baidu.com/article/c1a3101eb52cd8de656deba6.html Win8的UAC关闭不生效?彻底关闭Win8的UAC? 1. ...

  6. RTMP协议规范(转载)

    译序: 本文是为截至发稿时止最新 Adobe 官方公布的 RTMP 规范.本文包含 RTMP 规范的全部内容.是第一个比较全面的 RTMP 规范的中译本.由于成文时间仓促,加上作者知识面所限,翻译错误 ...

  7. 【Sprint3冲刺之前】日历表的事件处理和管理(刘铸辉)

    我的Sprint2冲刺——日历表的事件处理和管理(刘铸辉,刘静) 我的Sprint2冲刺计划领到的任务是和静姐结对编程,完成日历表的事件处理和管理,下面详细讲解下技术细节. 1.设计结构图 首先要画出 ...

  8. Linux 下编译安装OpenCV(zhuanzai)

    http://www.cnblogs.com/emouse/archive/2013/02/22/2922940.html Cmake的安装 OpenCV 2.2以后版本需要使用Cmake生成make ...

  9. soap的调用方式

    1.方式1    url:http://localhost:3651/recruit/index.asmx?WSDL post 内容: <soapenv:Envelope xmlns:soape ...

  10. 自动提交form表单

    <form class="form-inline" name='MD5form' method="post" action="<?php ...