Woburn Challenge 1996

Problem 6: Different Bases Multiplication

In normal everyday usage numbers are thought of in base ten. The reason for this is naturally due to humans having ten fingers on which to perform mathematical operations such as add, subtract and multiply. However, in computer technology, the use of low and high voltage states lends itself to thinking of operations defined on having only these two states. Hence, the binary system as a descriptive tool in computers in quite useful. Moreover, we could easily have a use for other number systems (cartoon characters couting in base 8, some alien species counting in base 97).

Your task is to take two different-base numbers, calculate their product, and return the answer in another base.

For example, "Find 128 * 359 in base 10."

Input

The input file contains 5 data sets.
The first line of each data set is the first number and its base.
The second line of each data set is the second number and its base.
The third line of each data set is the base in which the product is to be reported.
All bases will be integers from 2 to 10 inclusive.

Output

Give the product of the numbers in the specified base.
Each product will be less than or equal to 2 billion (base ten).

Sample Input

12 8
35 9
10
121 7
121 7
7

(and 3 more inputs)

Sample Output

320
14641

All Submissions
Best Solutions


Point Value: 5
Time Limit: 2.00s
Memory Limit: 16M
Added: Sep 29, 2008

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

I got all of them right, except for that one...

Well, your output ends in a single 0, but there should actually be 2 zeros at the end of that number. Hopefully that's enough for you to figure out what's going on.

Thanks alot! I finally figured out the problem.


Are any of the numbers negative?


Would it really be any more difficult if there were?

Mine wouldn't work o_O