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: CLOJ ERL F# JS PERL 6 TECS
Resource:COI 01

hide comments
2010-07-31 01:40:17 Vladimir Kirichenkoff
Don't read from the file and don't write to the file. Use stdin/stdout
2010-07-24 22:02:22 aalizzwell
absolutely no need to consider extra whitespaces in the input expression
2010-06-22 18:16:06 Chandra sekar
No. You SHOULD NOT print MASS.IN & MASS.OUT.
My IO was lik the following. It got AC! :)
((C)(C))
24
(((C)))
12
etc.

Last edit: 2010-06-22 20:26:01
2010-06-02 02:47:19 Karel Rodríguez Carmenates
could someone be more specific, about the input/output format
have I to write MASS.out, or read MASS.in
2010-03-28 20:58:31 RocknRolla
Should we have to print MASS.IN and MASS.out stuff??I am getting WA.......
can anyone clearly write I/O format...
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 © 2010 Sphere Research Labs. All Rights Reserved.