### BlueBook

## p309ex13: Calculator

Given two integers A and B (0 ≤ A, B < 2^32 - base 10), in bases B1 and
B2 (2 ≤ B1, B2 ≤ 10), output the result of either `+ - * /`

in
the integral base BF (2 ≤ BF ≤ 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

Line 1: One integer T (1 ≤ T ≤ 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: B1

Line 2: N1

Line 3: B2

Line 4: N2

Line 5: The operand (Either '+', '-', '*', or '/')

Line 6: BF

### Sample Input

2 10 123 10 456 + 10 8 777 5 333 - 2

### Sample Output

579 110100010

All Submissions

Best Solutions

**Point Value:** 5

**Time Limit:** 2.00s

**Memory Limit:** 16M

**Added:** Nov 01, 2008

**Languages Allowed:**

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

## Comments (Search)

magicalsoupon Feb 18, 2018 - 4:14:46 am UTC wowSroton Nov 30, 2011 - 10:56:53 pm UTC I don't get what this is asking?are you doing 2+123+10+456+10 in test case one. What does the program do? thank you

jargonon Dec 01, 2011 - 12:29:14 am UTC Re: I don't get what this is asking?The first case asks you to add 123 to 456.

The second case asks you to subtract 333 (in base 5) from 777 (in base 8) and to express the result in base 2.

HelloMelloCon Jan 02, 2011 - 9:20:50 pm UTC Undervalued ProblemIt's equal to Bases Multiplication (10pts), only you need to do more than just multiplication.

bbi5291on Jan 03, 2011 - 4:33:19 pm UTC Re: Undervalued Problem