NINJA KI GANIT

Posted: 25 Feb, 2021
Difficulty: Moderate

PROBLEM STATEMENT

Try Problem

Ninja always uses his calculator for doing addition, subtraction, multiplication, and division but due to some technical fault in his calculator only the “+” operator is working and all other operators are not in working condition.

Now his teacher gives him the question of subtraction, multiplication, and division, and now ninja is thinking of the solution of these questions by using the “+” operator as only the “+” operator is in working condition.

So help our ninja to do the subtraction, division, and multiplication with the help of addition.

So your task is to write a code that can do subtraction, multiplication, and division, and you are allowed to use only the “+” operator or we can say addition.

Input Format :

The first line of input contains the ‘T’ number of test cases.

The first line of each test case contains two integers ‘N’ and ‘M’.

Output Format :

For each test case print all three results subtraction result, multiplication result, division result respectively in form of a vector.
Note:
You do not need to print anything; it has already been taken care of. Just implement the function.

Constraints :

1 <= T <= 100
-1000 <= N <= 1000
-1000 <= M <= 1000  and M != 0 

Time Limit: 1 sec
Approach 1
  • For subtraction
    • Just change the sign of the second integer and simply add them.
    • For ex- integers ‘N=8’and ‘M=2’now after reversing the sign of ‘M’ we get ‘M=-2’now ‘N+M=8+(-2)=6’
  • For multiplication
    • Add the integer ‘N’ in itself for the ‘M’ times.
    • For ex- integers ‘N=8’ and ‘M=2’
    • Now add ‘N’ into itself for ‘2’ times
  • For division continuously subtract dividend from divisor and count is your quotient.
Try Problem