SAC '22 Code Challenge 3 Junior P4 - Normal Conversions

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 1.0s
Java 1.5s
Memory limit: 256M

Author:
Problem type

Having spent his last V-Buck, Max was upset, so Bob Xiong decided to cheer him up.

Bob told Max that he would buy him a Fortnite skin if he could solve this problem:

Given Q queries, convert a base b1 number, n, to base b2.

Since Max knows you are a great programmer, Max has asked you to help him.

Can you help Max solve his V-Buck crisis?

Constraints

1Q105

2b1,b210

1n10109

Note that n10 represents n in base 10.

Subtask 1 [30%]

b1 and b2 are each either 2 or 10.

Subtask 2 [70%]

No additional constraints.

Input Specification

The first line will contain Q, the number of queries.

The next Q lines will contain b1, n, and b2, the current base of the number, the number in that base, and the next base of the number, respectively.

Output Specification

Output Q lines, the number converted from base b1 to base b2.

Note that there should be no leading zeroes after converting.

Sample Input 1

Copy
2
2 101 10
10 64 2

Sample Output 1

Copy
5
1000000

Sample Input 2

Copy
2
3 22 10
10 6 4

Sample Output 2

Copy
8
12

Comments

There are no comments at the moment.