UVa 355

From Algorithmist
Jump to navigation Jump to search

355 - The Bases Are Loaded[edit]

Summary[edit]

This is very similar to question UVa 389. Given the base of the number and the base to convert as well a number find its converted value. If the number is not a valid base number print is an illegal base x number where x is the base you are converting from.

Explanation[edit]

Look at the page for UVa 389. Convert the number of the base b if it is a base b number to base a.

Gotchas[edit]

  • The numbers being tested are likely > 2^31 use unsigned int or long long

Input[edit]

2 10 10101
5 3 126
15 11 A4C
16 16 7FFFFFFFFFF
2 3 0

Output[edit]

10101 base 2 = 21 base 10 
126 is an illegal base 5 number 
A4C base 15 = 1821 base 11
7FFFFFFFFFF base 16 = 7FFFFFFFFFF base 16
0 base 2 = 0 base 3

See Also[edit]

References[edit]