#CODEFORCESP5672. Bear and Strings
Bear and Strings
Bear and Strings
题面翻译
给定一个字符串,找出所有的子串,该子串包含 这个单词,输出满足条件的子串个数。
题目描述
The bear has a string (record is the string's length), consisting of lowercase English letters. The bear wants to count the number of such pairs of indices , that string contains at least one string "bear" as a substring.
String contains string "bear", if there is such index , that , , , .
Help the bear cope with the given problem.
输入格式
The first line contains a non-empty string . It is guaranteed that the string only consists of lowercase English letters.
输出格式
Print a single number — the answer to the problem.
样例 #1
样例输入 #1
bearbtear
样例输出 #1
6
样例 #2
样例输入 #2
bearaabearc
样例输出 #2
20
提示
In the first sample, the following pairs match: .
In the second sample, the following pairs match: $ (1,4),(1,5),(1,6),(1,7),(1,8),(1,9),(1,10),(1,11),(2,10),(2,11),(3,10),(3,11),(4,10),(4,11),(5,10),(5,11),(6,10),(6,11),(7,10),(7,11) $ .