AtCoder Grand Contest 027
翻译中…
Problem Statement
翻译中…
There is a string $s$ consisting of a and b. Snuke can perform the following two kinds of operation any number of times in any order:
翻译中…
- Choose an occurrence of
aaas a substring, and replace it withb. - Choose an occurrence of
bbas a substring, and replace it witha.
翻译中…
How many strings $s$ can be obtained by this sequence of operations? Find the count modulo $10^9 + 7$.
翻译中…
Constraints
翻译中…
$1 \leq |s| \leq 10^5$$s$consists ofaandb.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
s
翻译中…
Output
翻译中…
Print the number of strings $s$ that can be obtained, modulo $10^9 + 7$.
翻译中…
样例
Input #1
aaaa
Output #1
6
Six strings can be obtained:
- `aaaa`
- `aab`
- `aba`
- `baa`
- `bb`
- `a`
Input #2
aabb
Output #2
5
Five strings can be obtained:
- `aabb`
- `aaa`
- `bbb`
- `ab`
- `ba`
Input #3
ababababa
Output #3
1
Snuke cannot perform any operation.
Input #4
babbabaaba
Output #4
35
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。