Question: Problem Statement Idle Ivan was lounging by a river trying to figure out a way to increase the amount of coins Ci that he had

Problem Statement
Idle Ivan was lounging by a river trying to figure out a way to increase the amount of coins Ci that he had in his pocket without doing a lot of work. A clever gnome appeared and made him a proposition: he would double the money in Ivan's pocket every time Ivan crossed the bridge, but in return he asked for a payment of P coins after each bridge crossing (and after doubling the money). Depending on the values of P and Ci, can Ivan expect to earn money from this deal?
Input
The first and only line of input consists of P and Ci, the cost to cross the bridge once and the number of coins Ivan starts with. You may assume 2Ci >= P.
Output
Output the number of coins Ivan will have after crossing the bridge as many times as possible. If Ivan can infinitely cross the bridge and gain more coins, output "infinite".
Sample Input:
87
Sample Output:
0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!