The Cunning Fox

2.6

12 votes
Problem

A fox requests a monkey sitting on the tree for some fruits but the fox denies it. He orders the fox to solve a puzzle. The puzzle statement is “When you add two numbers, you subtract them, and when you subtract two numbers, you multiply them and when you multiply two numbers you divide them (Quotient is an integer), so if I give you two numbers and I ask you to do an operation, will you be able to find the correct output? If yes, the tree is all yours."

Now as the monkey doesn't knows how to code, so he asks for your help and you have to help him out by writing a related program for the same.

N.B. 1 for add, 2 for subtract and 3 for multiply.

Constraints:

1<=Numbers<=18000

Example 1:

Input: Enter the two numbers and enter a single number for the selection of an operation.

5 6

1

Output:

-1

Example 2:

Input:

30 6

3

Output:

5

Explanation:

Example 1 Two numbers are 5 and 6 and 1 represents addition but as the fox says in the puzzle, the addition means subtraction and hence the result 5-6=-1

Example 2 Two numbers are 30 and 6 and 3 represents multiplication but as the fox says in the puzzle, the multiplication means division and hence the result 30/6=5

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?