

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
英小文字のみからなる文字列 が与えられます。 下記の条件を満たす空でない文字列 の個数を で割ったあまりを出力してください。
を つ連結して得られる文字列 が、 に(連続とは限らない)部分列として含まれる。
制約
- は英小文字のみからなる長さ 以上 以下の文字列
入力
入力は以下の形式で標準入力から与えられる。
出力
答えを出力せよ。
入力例 1Copy
ababbaba
出力例 1Copy
8
問題文中の条件を満たす文字列 は、a
、aa
、ab
、aba
、b
、ba
、bab
、bb
の 個です。
入力例 2Copy
zzz
出力例 2Copy
1
問題文中の条件を満たす文字列 は、z
のみです。
zzz
から、文字列 zz
を部分列として得る方法は、
zz
、 zz
、 zz
の 通りありますが、文字列 z
は答えに 回だけ寄与することに注意してください。
入力例 3Copy
ppppqqppqqqpqpqppqpqqqqpppqppq
出力例 3Copy
580
Score : points
Problem Statement
You are given a string consisting of lowercase English letters. Print the number of non-empty strings that satisfy the following condition, modulo .
The concatenation of two copies of is a subsequence of (not necessarily contiguous).
Constraints
- is a string consisting of lowercase English letters whose length is between and , inclusive.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1Copy
ababbaba
Sample Output 1Copy
8
The eight strings satisfying the condition are a
, aa
, ab
, aba
, b
, ba
, bab
, and bb
.
Sample Input 2Copy
zzz
Sample Output 2Copy
1
The only string satisfying the condition is z
.
Note that this string contributes to the answer just once, although there are three ways to extract the subsequence zz
from zzz
: zz
, zz
, and zz
.
Sample Input 3Copy
ppppqqppqqqpqpqppqpqqqqpppqppq
Sample Output 3Copy
580