luogu#P7888. 「MCOI-06」Distinct Subsequences
「MCOI-06」Distinct Subsequences
Problem Description
You are given a string consisting of lowercase letters.
Define the value of a string as the number of distinct non-empty subsequences of this string, where a subsequence is allowed to be the whole string itself.
Find the sum of the values of all subsequences of . Output the answer modulo .
Input Format
The first line contains a string consisting of lowercase letters.
Output Format
Output one line containing the answer.
ab
5
sapnap
593
abcbdabcbabcd
938773
tobeornottobethatisthequestion
769276982
Hint
Constraints
This problem uses bundled testdata.
- Subtask 1 (5 pts): .
- Subtask 2 (10 pts): .
- Subtask 3 (20 pts): and consists only of
aandb. - Subtask 4 (30 pts): .
- Subtask 5 (35 pts): no special restrictions.
For of the testdata, , and is guaranteed to consist only of lowercase letters.
Translated by ChatGPT 5