编程介的小学生 2017-09-25 16:20 采纳率: 20.5%
浏览 731
已采纳

Relative atomic mass

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 12of 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

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-10-14 15:45
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序