I Thought of a Number
InterviewTime limit1sMemory limit1024 MB
Given a and b, find the starting number that becomes b after dividing by a, subtracting a, and repeating those two steps once more.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
One day Bobi told his brother Ivo: I thought of a number. Find it if you can. Divide it by a, subtract a from the result, and perform the same two steps again on the new number. The final result is b. Help Ivo by writing a program think that, given a and b, finds the number Bobi thought of.
Input
The input contains two integers a and b from standard input.
Output
Print the number Bobi thought of to standard output.
Constraints