#P1634. Infection Spread in Beasts
Infection Spread in Beasts
Infection Spread in Beasts
A disease outbreak has occurred among a group of beasts. Initially, one beast is infected. In each round, each infected beast infects \(x\) new beasts. After \(n\) rounds of infection, you are to determine the total number of infected beasts.
The total number of infected beasts can be computed using the geometric series:
[ S = 1 + x + x^2 + \cdots + x^n = \begin{cases} \frac{x^{n+1}-1}{x-1}, & \text{if } x \neq 1, \ n+1, & \text{if } x = 1. \end{cases} ]
Note that the initial infected beast is counted as well.
inputFormat
The input consists of two positive integers \(x\) and \(n\) separated by spaces, where:
- \(x\) denotes the number of beasts each infected beast infects per round.
- \(n\) denotes the number of rounds of infection.
outputFormat
Output a single integer representing the total number of infected beasts after \(n\) rounds.
sample
3 2
13