luogu#P9164. 「INOH」Round 1 - 狂气
「INOH」Round 1 - 狂气
Problem Description
There is an infinite sequence . The array index starts from . Initially, , and all other positions are .
There are operations:
- For all odd , set .
- For all even , set .
You need to find the sequence after all operations are completed.
To make output easier, you only need to output the value of $( \displaystyle\prod_{i = 1}^{m} (a_i + 1))\bmod 998244353$.
Input Format
The first line contains a positive integer .
The second line contains a string of length , representing the operation sequence.
Output Format
One line, representing the value of $( \displaystyle\prod_{i = 1}^{m} (a_i + 1)) \bmod 998244353$.
5
11221
200
13
1122121212212
400201782
Hint
Sample 1 Explanation
After operations, the first five terms of the sequence are:
, , , , .
This problem uses bundled testdata.
- Subtask 0 (10 pts): .
- Subtask 1 (20 pts): the operation sequence is of the form .
- Subtask 2 (20 pts): the operation sequence is generated randomly.
- Subtask 3 (50 pts): no special constraints.
For of the testdata, .
Please pay attention to the impact of constant factors on runtime efficiency.
Translated by ChatGPT 5