AT_abc400_b [ABC400B] Sum of Geometric Series
Description
You are given two positive integers $ N $ and $ M $ .
Let $ X = \displaystyle\sum_{i = 0}^{M} N^i $ . If $ X \leq 10^9 $ , print the value of $ X $ . If $ X > 10^9 $ , print `inf`.
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ M $
Output Format
Print the value of $ X $ or `inf` as specified by the problem statement.
Explanation/Hint
### Sample Explanation 1
$ X = 1 + 7 + 49 + 343 = 400 $ . Since $ 400 \leq 10^9 $ , print $ 400 $ .
### Sample Explanation 2
$ X = 1000001000001 > 10^9 $ , so print `inf`.
### Constraints
- $ 1 \leq N \leq 10^9 $
- $ 1 \leq M \leq 100 $
- All input values are integers.