Relative atomic mass
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
quantity, the ratio of the average mass of atoms of an element (from a single
given sample or source) to 1
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.
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.
H
C
O
HOH
CHHHCHHOH
12
16
18
46
#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的更多相关文章
- HDU 5949 Relative atomic mass 【模拟】 (2016ACM/ICPC亚洲区沈阳站)
Relative atomic mass Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Oth ...
- 【HDOJ5949】Relative atomic mass(签到)
题意:给定一个只由H.C.O三种分子组成物质的分子式,求相对分子质量 len<=10 思路:队友写的 #include <stdio.h> #include <vector&g ...
- 2016ACM/ICPC亚洲区沈阳站-重现赛赛题
今天做的沈阳站重现赛,自己还是太水,只做出两道签到题,另外两道看懂题意了,但是也没能做出来. 1. Thickest Burger Time Limit: 2000/1000 MS (Java/Oth ...
- 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 ...
- ACM Shenyang Onsite 2016 题目
A. Thickest Burger 1000ms 262144K ACM ICPC is launching a thick burger. The thickness (or the heig ...
- 2016ACM/ICPC亚洲区沈阳站 Solution
A - Thickest Burger 水. #include <bits/stdc++.h> using namespace std; int t; int a, b; int main ...
- The 2016 ACM-ICPC Asia Shenyang Regional Contest
A. Thickest Burger 大数 × 2 + 小数 #include <cstdio> #include <algorithm> using namespace st ...
- 2016 ACM/ICPC亚洲区沈阳站
A B C D E F G H I J K L M O O O $\varnothing$ $\varnothing$ $\varnothing$ $\varnothing$ $\varnothi ...
- absurd, abundant
absurd How: absolutely, completely, clearly, faintly, manifestly, obviously, patently, quite, rather ...
随机推荐
- Dance In Heap(二):一些堆利用的方法(上)
0×00 前面的话 在前面的文章里我们稍微有点啰嗦的讲解了堆中的一些细节,包括malloc.free的详细过程,以及一些检查保护机制,那在这篇文章里,我们就开始结合这些机制,以64位为例来看一看如何对 ...
- 江湖问题研究-- intent传递有没有限制大小,是多少?
出门一步,便是江湖.江湖上有很多流言. 比方这条: intent传递是有限制大小的,详细在40KB左右. 当然也有传言说是1M左右. 数百头母驴为何半夜慘叫? 小卖部安全套为何屡遭黑手? 女生宿舍内裤 ...
- 我猜你不会使用try-catch
我猜你不会用try-catch,废话不说,首先看看大多数的人是怎么用的吧,或许你会躺枪哦. 请问.看到上面的代码,你的第一印象是啥.我猜你会说,"我不想看,我不想看,看不懂".事实 ...
- dwr框架中DWRUtil的方法
dwr框架中DWRUtil的方法 2008-10-14 17:57:23| 分类: JAVA | 标签: |举报 |字号大中小 订阅 7. util.js 功能 util.js包含了一些工 ...
- java 对账关键点
原理:双方交易信息对比是否平账 注意:对账bean必须重写 equals 方法 如图: //对账方法
- 二进制安装Mysql 5.6(免编译)
安装系统基础软包 yum install -y make bc perl gcc openssl openssl-devel ncurses ncurses-devel 安装方式:二进制免编译安装 查 ...
- disabled和readonly
项目中,有一个input控件,input的值需要通过点击一个javascript链接,从弹出的对话框中所列出的项中选择.而不能从input框中直接输入. 刚开始将input的disabled属性设置为 ...
- js thiskeyword
相信大家都接触过this了,那么 this究竟是什么意思呢?看其字面意思就是个代词.指代其它的一些东西. 那么我们在程序其中,事实上也是一样.this也是个代词. 比方我们在java其中,this的k ...
- HDU 5336 XYZ and Drops 2015 Multi-University Training Contest 4 1010
这题的题意是给你一幅图,图里面有水滴.每一个水滴都有质量,然后再给你一个起点,他会在一開始的时候向四周发射4个小水滴,假设小水滴撞上水滴,那么他们会融合,假设质量大于4了,那么就会爆炸,向四周射出质量 ...
- Lance老师UI系列教程第九课->高仿比特币监控大师
http://blog.csdn.net/lancees/article/details/22898971