|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||64 MB||0||0||0||0.000%|
Our body is made up of protein which plays a crucial role in almost all biological processes and amino acids are the building blocks of it. A large proportion of our cells, muscles and tissue is made up of amino acids, meaning they carry out many important bodily functions, such as giving cells their structure. The key elements of an amino acid are carbon (C), hydrogen (H), oxygen (O), nitrogen (N) and sulfur (S). We need a program to help us calculate the molecular weight of a given amino acid from its chemical formula. For example, the chemical formula for Alanine is O2C3NH7 ; thus, Alanine contains two atoms of oxygen, three atoms of carbon, one atom of nitrogen and seven atoms of hydrogen. Since we know the molecular weight of each element as follows:
Therefore, the molecular weight of Alanine can be computed as
molecular weight = 2x15.9994 + 3x12.011 + 1x14.00674 +7x1.00794 = 89.09412
and Methionine, whose formula is C5H11NO2S, would have molecular weight of 149.213880.
The first line of input is an integer n (1<= n <= 100) indicating the number of test cases. Then n strings follow that describes a formula of amino acid which contains five elements stated above with their corresponding numbers of atoms. Each formula is less than 100 characters.
Calculated molecular weight of a given amino acid. If the formula contains invalid letter (not C or H or O or N or S), then output “Invalid formula”. The output must be real numbers with 4-digit decimal fraction.
6 S O2C3NH7 C2H5NO2 C5H11NO2S C6N14N2O2 OX
32.0660 89.0941 75.0672 149.2139 328.1726 Invalid formula