DWITE '08 R3 #3 - Unicorns and Teaspoons

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem type
DWITE Online Computer Programming Contest, December 2008, Problem 3

Google's calculator works with some pretty weird units of measure. Have you tried searching for a value of the answer to life the universe and everything / number of horns on a unicorn? (btw, it's 42) We'll try to work with just the imperial units of volume for now.

You'll need this table of conversions:

5 fluid ounce (oz)1 gill (gill)
4 gill (gill)1 pint (pt)
2 pint (pt)1 quart (qt)
4 quart (qt)1 gallon (gal)

The input will contain 5 lines in a format of: value unit1 in unit2, where the goal is to convert from unit1 to unit2, for a given value. 1 \le value \le 1000. Units are expressed as keys inside brackets in the table above.

The output will contain 5 integers – the converted values. The supplied input will always work out to be an integer answer.

Sample Input

10 oz in gill
20 oz in pt
2 gal in oz
1 gal in qt
2 pt in pt

Sample Output

2
1
320
4
2

Problem Resource: DWITE

Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported

Comments

There are no comments at the moment.