#abc335f. F - Hop Sugoroku
F - Hop Sugoroku
Score : points
问题描述
有一行 个正方形,标记为 ,并且有一个长度为 的序列 。
初始时,正方形 被涂成黑色,其余 个正方形被涂成白色,并且一个棋子位于正方形 上。
你可以重复执行以下操作任意次数,包括零次:
- 当棋子位于正方形 时,选择一个正整数 ,并将棋子移动到正方形 。
- 此处,你不能进行使 的移动。
- 然后,将正方形 涂成黑色。
求在所有操作结束后能够被涂成黑色的正方形组合的数量,结果对 取模。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There is a row of squares labeled and a sequence of length .
Initially, square is painted black, the other squares are painted white, and a piece is placed on square .
You may repeat the following operation any number of times, possibly zero:
- When the piece is on square , choose a positive integer and move the piece to square .
- Here, you cannot make a move with .
- Then, paint the square black.
Find the number of possible sets of squares that can be painted black at the end of the operations, modulo .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
5
1 2 3 1 1
Sample Output 1
8
There are eight possible sets of squares painted black:
- Square
- Squares
- Squares
- Squares
- Squares
- Squares
- Squares
- Squares
Sample Input 2
1
200000
Sample Output 2
1
Sample Input 3
40
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Sample Output 3
721419738
Be sure to find the number modulo .
update @ 2024/3/10 01:24:31