luogu#P7888. 「MCOI-06」Distinct Subsequences

「MCOI-06」Distinct Subsequences

Problem Description

You are given a string SS 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 SS. Output the answer modulo 109+710^9+7.

Input Format

The first line contains a string SS 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): S11|S|\le 11.
  • Subtask 2 (10 pts): S22|S|\le 22.
  • Subtask 3 (20 pts): S100|S|\le 100 and SS consists only of a and b.
  • Subtask 4 (30 pts): S5000|S|\le 5000.
  • Subtask 5 (35 pts): no special restrictions.

For 100%100\% of the testdata, 1S1061\le |S|\le 10^6, and SS is guaranteed to consist only of lowercase letters.

Translated by ChatGPT 5