Sphere Online Judge

SPOJ Problem Set (classical)

4031. Mass of Molecule

Problem code: MMASS

Hóa chất chỉ gồm các nguyên tố C, H, O có trọng lượng 12,1, 16 tương ứng.

Nó được biểu diễn dạng "nén", ví dụ COOHHH là CO2H3 hay CH (CO2H) (CO2H) (CO2H) là CH(CO2H)3. Nếu ở dạng nén thì số lần lặp >=2 và <=9.

Tính khối lượng hóa chất.

Input

Gồm một dòng mô tả hóa chất không quá 100 kí tự chỉ gồm C, H, O, (, ), 2,..,9.

Output

Khối lượng của hóa chất, luôn <=10000.

Sample

MASS.IN

COOH

MASS.OUT

45
 
MASS.IN

CH(CO2H)3

MASS.OUT

148
 
MASS.IN

((CH)2(OH2H)(C(H))O)3

MASS.OUT

222
 


Added by:~!(*(@*!@^&
Date:2009-03-08
Time limit:1s
Source limit:50000B
Languages:All except: ERL TECS JS
Resource:COI 01

hide comments
2009-08-05 11:59:37 smilitude
I think there isnt any extra whitespace in the middle of the input expression. I used gets, got WA then used scanf, and got AC.

Last edit: 2009-08-05 12:01:03
2009-06-18 19:42:47 The Raven
This problem contains extra whitespace in the input expressions.
2009-05-14 11:57:40 Abhishek Kona
Timed out always.
Please be a bit more clear about input formats
2009-04-17 20:43:00 ­Surendra
In C++,
I got WA with getline,but AC with cin
SPOJ System © 2008-2010 Sphere Research Labs. All Rights Reserved.