#P11577. Earliest Infection Time
Earliest Infection Time
Earliest Infection Time
When a person gets infected, they will infect \(R\) people on the next day and then stop infecting others. No person is infected more than once. Initially, only one person is infected at time \(t = 0\). At each subsequent day, each person infected the previous day infects \(R\) new people. Thus, the total number of infected people by day \(t\) is given by the sum:
$$\sum_{i=0}^{t} R^i = \frac{R^{t+1}-1}{R-1}\quad \text{(for } R\neq 1\text{)} $$For the special case when \(R=1\), the total equals \(t+1\). Given an integer \(P\), determine the smallest number of days needed so that a total of \(P+1\) people are infected.
inputFormat
The input consists of two integers R and P separated by a space.
R
: The number of people a person infects the next day.P
: Additional number of people (besides the initial patient) needed to be infected.
outputFormat
Output a single integer representing the minimum number of days required for \(P+1\) people to be infected.
sample
1 0
0