프로그램 명: mass
제한시간: 1 초

[문제 요약] 분자식을 입력으로 받아 이 분자식의 질량을 구하는 문제.

원소는 C , H , O , N 만 입력되고 각 원소의 질량은

예를 들어 , C6H5OH 이면 질량은 94.108 g/mol 이다.
6×(12.01 g/mol) + 6×(1.008 g/mol) + 1×(16.00 g/mol).
입력은 80 자를 넘지 않고 원소가 1 개이면 생략하고 원소의 갯수는 2 이상 80 이하이다. 출력은 소수 네 자리에서 반올림하여 세자리까지 출력 한다.
An organic compound is any member of a large class of chemical compounds whose molecules contain carbon. The molar mass of an organic compound is the mass of one mole of the organic compound. The molar mass of an organic compound can be computed from the standard atomic weights of the elements.

When an organic compound is given as a molecular formula, Dr. CHON wants to find its molar mass. A molecular formula, such as C3H4O3, identifies each constituent element by its chemical symbol and indicates the number of atoms of each element found in each discrete molecule of that compound. If a molecule contains more than one atom of a particular element, this quantity is indicated using a subscript after the chemical symbol.

In this problem, we assume that the molecular formula is represented by only four elements, ‘C’ (Carbon), ‘H’ (Hydrogen), ‘O’ (Oxygen), and ‘N’ (Nitrogen) without parentheses.

The following table shows that the standard atomic weights for ‘C’, ‘H’, ‘O’, and ‘N’.

Atomic Name Carbon Hydrogen Oxygen Nitrogen
Standard Atomic Weight 12.01 g/mol 1.008 g/mol 16.00 g/mol 14.01 g/mol

For example, the molar mass of a molecular formula C6H5OH is 94.108 g/mol which is computed by 6×(12.01 g/mol) + 6×(1.008 g/mol) + 1×(16.00 g/mol). Given a molecular formula, write a program to compute the molar mass of the formula.

입력

The chemical symbol is given by a capital letter and the length of the string is greater than 0 and less than 80. The quantity number n which is represented after the chemical symbol would be omitted when the number is 1 ( 2 <= n <= 99 ).

출력

The line should contain the molar mass of the given molecular formula.

입출력 예

입력

C

출력

12.010

입력

C6H5OH

출력

94.108

입력

NH2CH2COOH

출력

75.070

입력

C12H22O11

출력

342.296
출처: The 31th Annual ACM Programming Contest ASIA Regional - Seoul  problem A

[질/답] [제출 현황] [푼 후(3)]
[ 채 점 ] [홈으로]  [뒤 로]