Easy IPhone | Solve programming problems on HackerEarth
Ricky is crazy about IPhones, he want to use IPhones throughout his life.
Ricky has X number of IPhones, he can use only one IPhone for a year. After one year of use an IPhone becomes useless and he cannot use it any more. The company has an exchange offer for Ricky; he will get one new IPhone if he will return Y number of useless IPhones. This new IPhone can be used like any other new IPhones.
Now you have to tell for how many years can he use IPhones?
Ricky is crazy about IPhones, he want to use IPhones throughout his life.
Ricky has X number of IPhones, he can use only one IPhone for a year. After one year of use an IPhone becomes useless and he cannot use it any more. The company has an exchange offer for Ricky; he will get one new IPhone if he will return Y number of useless IPhones. This new IPhone can be used like any other new IPhones.
Now you have to tell for how many years can he use IPhones?
int X, Y;
scanf ("%d %d", &X, &Y);
int ret = 0, useless = 0;
while (X) {
ret += X;
useless += X;
X = useless / Y;
useless %= Y;
}
printf ("%d\n", ret);
Read full article from Easy IPhone | Solve programming problems on HackerEarth