P27906 [洛谷] [GESP202312 Level 3] Catfish Division
普及-
题目描述

Problem Description

On a beach, there is a pile of fish, and \( N \) cats come to divide them. The first cat divides the pile into \( N \) equal parts, with \( i < N \) extra fish. This cat throws the extra \( i \) fish into the sea and takes one part. The second cat then divides the remaining fish into \( N \) equal parts, again with \( i \) extra fish, which it also throws into the sea and takes one part. This process continues with the third, fourth, ..., and the \( N \)-th cat, who all divide the remaining fish into \( N \) equal parts, throw away the extra \( i \) fish, and take one part.

Write a program that, given the number of cats \( N \) and the number of extra fish \( i \) thrown into the sea each time, outputs the minimum number of fish on the beach such that each cat can get a share.

For example: If two cats come to divide the fish \( N = 2 \), and the number of fish thrown away each time is \( i = 1 \), to ensure each cat can get a fish, the second cat needs to take 1 fish, leaving 3 fish to be divided. The first cat had \( 3 \times 2 + 1 = 7 \) fish to divide initially.

Input Format

There are two lines in total. The first line contains an integer \( N \), and the second line contains an integer \( i \).

It is guaranteed that \( 0 < N < 10 \); \( i < N \).

Output Format

A single line containing an integer, representing the minimum number of fish on the beach that satisfies the requirement.

Sample Input and Output

Sample Input #1

2
1

Sample Output #1

7

Sample Input #2

3
1

Sample Output #2

25

Notes

Sample Explanation 2

Three cats come to divide the fish \( N = 3 \), and the number of fish thrown away each time is \( i = 1 \). To ensure each cat can get a fish, the third cat needs to take 3 fish (taking 1 or 2 fish does not satisfy the requirement), leaving 10 fish to be divided. The second cat had \( 10 \times 3/2 + 1 = 16 \) fish to divide. The first cat had \( 16 \times 3/2 + 1 = 25 \) fish to divide initially.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 1
样例输出
7