#P6394. 樱花,还有你
樱花,还有你
Description
Sentences related to the task have been bolded.
But don’t rush. Let’s just keep walking slowly like this. No need to stop or look back. Aren’t there still sakura trees ahead? I calculated it: you need to collect exactly sakura petals. I also found that under the -th tree, you can collect at most sakura petals (collecting sakura petals also counts as collecting sakura petals).
Now, let me test you. How many different plans are there to collect exactly sakura petals?
In particular, if you cannot collect sakura petals, please tell me impossible.
Note: If you reach sakura petals early, you may tell me immediately, or you may keep walking with me. But after collecting sakura petals under the -th tree, you must report your result. During the process, if you tell me after collecting sakura petals under any tree, the resulting plans are considered different.
Input Format
The first line contains two positive integers , meaning you need to collect sakura petals, and there are sakura trees ahead.
The next line contains positive integers , where means you can collect at most sakura petals under the -th sakura tree.
Output Format
Output one integer per line, representing the number of plans to collect exactly sakura petals.
Since the answer may be very large, output the result modulo .
In particular, if it is impossible to collect sakura petals, output the string impossible.
3 4
1 1 1 1
5
10 9
9 6 8 7 9 6 5 4 3
68345
10 5
2 2 2 2 1
impossible
Hint
Sample Explanation #1
We use the following way to represent a plan: , where , means you report after finishing collecting sakura petals under the -th tree, and means you collected sakura petals under the -th tree.
Then there are plans: , , , , .
Sample Explanation #3
You can collect at most sakura petals, so you cannot collect sakura petals, and the output is impossible.
Constraints
This problem uses bundled tests.
- Subtask 1 (5 Points), .
- Subtask 2 (20 Points), .
- Subtask 3 (55 Points), .
- Subtask 4 (20 Points), .
For of the testdata, , .
Background (Continued)
Someone as smart as you will surely stand under some tree, holding lovely sakura petals, and ask for credit from me like a child.
Then don’t blame me for granting your wish. I will lightly jump up, wrap my arms around your neck, lift your mask, and taste your lips.
Will you say, “Sweet like sakura”?
Anyway, my face must already be as red as sakura.
...
When you read this letter, don’t cry...
What winter took away from this city, spring will make up for us.
When you get better, go watch sakura with me, okay?
Yours,
Yi
Translated by ChatGPT 5
京公网安备 11011102002149号