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 ...
随机推荐
- 托管和非托管转换新方法:Marshaling Library(zz) 【转】
托管和非托管转换新方法:Marshaling Library(zz) 托管和非托管转换新方法:Marshaling Library(zz) http://hi.baidu.com/superql/bl ...
- C中的继承和多态
昨天同学面试被问到这个问题,很有水平,以前都没有遇到过这个问题,一时自己也不知道怎么回答. 网上学习了一下,记录以备后用! C/C++ Internals : 里面的问题都写的不错,可以读读! Ref ...
- 谈一次Linux的木马攻击数据爆满造成的Mysql无法启动
起初以为是mysql它们之间的扩展没有开启! 后来发现,木马的确使它初始化了,最开始没有用图形化界面 而后,修改并且开启所有pdo扩展 VIM基本操作(除了插入,其它的命令前提是按ESC): 插入: ...
- 用ELK 实时处理搜索日志
转载请标明原处:http://blog.csdn.net/hu948162999/article/details/50563110 本来这块业务 是放到SolrCloud上去的 , 然后 採用solr ...
- C++获取站点的ip地址
#include "stdafx.h" #include <winsock2.h> #pragma comment (lib,"ws2_32.lib&q ...
- VCC/AVCC/VDD/AVDD区别
V*与AV*的区别是:数字与模拟的区别CC与DD的区别是:供电电压与工作电压的区别(通常VCC>VDD): 数字电路供电VCC 模拟电路供电AVCCVDD是指工作电压,就是供电进芯片的 AVDD ...
- mysql 数据类型+约束+关联
1.什么是存储引擎存储引擎就是表的类型,针对不同的存储引擎,mysql会有不同的处理逻辑 2.存储引擎介绍InnoDB| DEFAULT | Supports transactions, row-le ...
- 关于arr.map()问题
最近看map实现原理, Array.prototype._map = function(fn, context) { console.log(fn, context) var temp = []; i ...
- PE添加Style
1. <style id="NumberStyle"> <setting> <param name="option"> ...
- Webkit二:RenderTree 创建
RenderObject 作为所有Render 树节点的基类,完全类似与DOM树中的Node基类,它是构成Render 树的基础,作用非比寻常,其中包含了构成Render 树所可能涉及到的一些基本属性 ...