BlueBook - Calculator

View as PDF

Submit solution

Points: 7
Time limit: 1.0s
Memory limit: 16M

Problem type
BlueBook

Given two integers A and B (0 \le A, B < 2^{32} - base 10), in bases B_1 and B_2 (2 \le B_1, B_2 \le 10), output the result of either + - * / in the integral base B_F (2 \le B_F \le 10). The resulting answer will be less than 2^{32} in base 10, and will always be positive.

Perform integer division (5/2 = 2) on the operands. Substitute the operand into (A <operand here> B) - so you should perform (A-B), (A/B), etc.

Input Specification

Line 1: One integer T (1 \le T \le 100) denoting the number of test cases.
T test cases follow, and each test case consists of 6 lines, with test cases separated by newlines.

Each test case has the following format:
Line 1: B_1
Line 2: A
Line 3: B_2
Line 4: B
Line 5: The operand (Either +, -, *, or /)
Line 6: B_F

Sample Input

2
10
123
10
456
+
10

8
777
5
333
-
2

Sample Output

579
110100010

Comments

There are no comments at the moment.