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 (0A,B<232 - base 10), in bases B1 and B2 (2B1,B210), output the result of either + - * / in the integral base BF (2BF10). The resulting answer will be less than 232 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 (AB), (A/B), etc.

Input Specification

Line 1: One integer T (1T100) 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: B1
Line 2: A
Line 3: B2
Line 4: B
Line 5: The operand (Either +, -, *, or /)
Line 6: BF

Sample Input

Copy
2
10
123
10
456
+
10

8
777
5
333
-
2

Sample Output

Copy
579
110100010

Comments

There are no comments at the moment.