New Language

4.1

7 votes
Basic Programming, Basics of Implementation, Easy, Implementation
Problem

A new mathematical language (let's call it Ninja) is discovered, in which 8 is completely missing.
So, new counting becomes (1,2,3,4,5,6,7,9,10,...). Whole counting is written without 8.
For example, 29 comes after 27,90 comes after 79, etc.
Thus 27+1=29, 79+1=90.
Now, your task is to perform addition, subtraction, multiplication and division operations on two numbers in this new language Ninja.
NOTE : The final output also has to be in the language Ninja.

Input Format
The first line contains an integer, T, denoting the number of test cases.
For each test case, two integers a and b are given, separated with any one of the above operation (+,,,/).
It is guaranteed that answer will not be negative.
For division operation, you have to answer integer division.

Output Format
For each test case, print the output of operation in Ninja.

Constraints

  • 1T105
  • 0a,b109( a and b are in Ninja language )
  • b0 for division(/) operation
  • ab for subtract() operation
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Explanation for 9×9=71 is given only.
First Try to learn how to calculate multiply in math language. For example, if we want to calculate 3×4, then write counting in 3 rows and 4 columns and last number(12) will be 3×4.

enter image description here

Now, we have to calculate 9×9 in Ninja language. So, write counting in 9 rows and 9 columns in Ninja language. Last number of the grid (71) will be the answer.

enter image description here

Editor Image

?