#abc313g. G - Redistribution of Piles
G - Redistribution of Piles
Score : points
问题描述
设有编号为 到 的 个盘子,其中第 个盘子上有 个石头。此外,还有一个空袋子。
你可以按照任意顺序执行以下两种操作任意次数(包括零次):
- 从每个至少有一个石头的盘子上移除一个石头,并将移除的石头放入袋中。
- 当袋子中有 个或更多石头时,从袋子里取出 个石头,然后给每个盘子放一个石头。
令 表示在完成所有操作后,第 个盘子上的石头数量。请输出可以通过这些操作得到的长度为 的整数序列 的个数,结果对 取模。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are plates numbered through . Dish has stones on it. There is also an empty bag.
You can perform the following two kinds of operations any number of times (possibly zero) in any order.
- Remove one stone from each plate with one or more stones. Put the removed stones into the bag.
- Take stones out of the bag, and put one stone to each plate. This operation can be performed only when the bag has or more stones.
Let be the number of stones on plate after you finished the operations. Print the number, modulo , of sequences of integers of length that can result from the operations.
Constraints
Input
The input is given from Standard Input in the following format:
Output
Print the number, modulo , of possible sequences .
Sample Input 1
3
3 1 3
Sample Output 1
7
For example, becomes by the following procedure.
- Perform the first operation. becomes .
- Perform the first operation. becomes .
- Perform the second operation. becomes .
The following seven sequences can be the resulting .
Sample Input 2
1
0
Sample Output 2
1
There are one sequence, , that can be the resulting .
Sample Input 3
5
1 3 5 7 9
Sample Output 3
36
Sample Input 4
10
766294629 440423913 59187619 725560240 585990756 965580535 623321125 550925213 122410708 549392044
Sample Output 4
666174028
update @ 2024/3/10 08:56:41