atcoder#CF17FINALG. Mancala
Mancala
Score : points
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 of length , let be the minimum score that can be obtained when the game is played on .
Find the sum of over all sequences of length where each element is between and (inclusive). Since it can be extremely large, find the answer modulo .
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the sum of modulo .
2 2
10
There are nine sequences of length where each element is between and . For each of them, the value of and how to achieve it is as follows:
- : (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 )
20 17
983853488