Problem Statement
Consider the following game:
- The game is played using a row of
squares and many stones. - First,
stones are put in Square . - A player can perform the following operation as many time as desired: "Select an integer
such that Square contains exactly stones. Remove all the stones from Square , and add one stone to each of the squares from Square to Square ." - The final score of the player is the total number of the stones remaining in the squares.
For a sequence
Find the sum of
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the sum of
Sample Input 1
Copy
2 2
Sample Output 1
Copy
10
There are nine sequences of length
: (Nothing can be done) : (Nothing can be done) : (Select Square , then Square ) : (Select Square ) : (Select Square ) : (Select Square , Square , then Square ) : (Nothing can be done) : (Nothing can be done) : (Select Square )
Sample Input 2
Copy
20 17
Sample Output 2
Copy
983853488
Comments