/*
  题意就是要找到包含“bear”的子串,计算出个数,需要注意的地方就是不要计算重复。
*/
1 #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define maxn 5005 char str[maxn];
int pos[maxn];
int main()
{
while(~scanf("%s",str))
{
int p = ;
memset(pos, , sizeof(int));
int len = (int)strlen(str);
for(int i = ;i < len;i++){
if(str[i] == 'b' && str[i+] == 'e' && str[i+] == 'a' && str[i+] == 'r')
pos[p++] = i;
}
// for(int i = 0;i < p;i++)
// printf("%d ",pos[i]);
int ans = ;
int num;
pos[] = -;
for(int i = ;i < p;i++){
num = (len - pos[i] - )*(pos[i]-pos[i-]);
//printf("%d*\n",num);
ans += num;
}
printf("%d\n",ans);
}
return ;
}

Codeforces Round #226 (Div. 2)B. Bear and Strings的更多相关文章

  1. Codeforces Round #226 (Div. 2)C. Bear and Prime Numbers

    /* 可以在筛选质数的同时,算出每组数据中能被各个质数整除的个数, 然后算出[0,s]的个数 [l,r] 的个数即为[0,r]的个数减去[0,l]个数. */ #include <stdio.h ...

  2. Codeforces Round #226 (Div. 2)A. Bear and Raspberry

    /* 贪心的找到相邻两项差的最大值,再减去c,结果若是负数答案为0. */ 1 #include <stdio.h> #define maxn 105 int num[maxn]; int ...

  3. 【计算几何】【状压dp】Codeforces Round #226 (Div. 2) D. Bear and Floodlight

    读懂题意发现是傻逼状压. 只要会向量旋转,以及直线求交点坐标就行了.(验证了我这俩板子都没毛病) 细节蛮多. #include<cstdio> #include<algorithm& ...

  4. 水题 Codeforces Round #302 (Div. 2) A Set of Strings

    题目传送门 /* 题意:一个字符串分割成k段,每段开头字母不相同 水题:记录每个字母出现的次数,每一次分割把首字母的次数降为0,最后一段直接全部输出 */ #include <cstdio> ...

  5. Codeforces Round #226 (Div. 2) B

    B. Bear and Strings time limit per test 1 second memory limit per test 256 megabytes input standard ...

  6. Codeforces Round #356 (Div. 2) C. Bear and Prime 100(转)

    C. Bear and Prime 100 time limit per test 1 second memory limit per test 256 megabytes input standar ...

  7. Codeforces Round #356 (Div. 2)B. Bear and Finding Criminals(水题)

    B. Bear and Finding Criminals time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  8. Codeforces Round #356 (Div. 2)A. Bear and Five Cards(简单模拟)

    A. Bear and Five Cards time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  9. Codeforces Round #356 (Div. 1) D. Bear and Chase 暴力

    D. Bear and Chase 题目连接: http://codeforces.com/contest/679/problem/D Description Bearland has n citie ...

随机推荐

  1. c++sort函数的用法浅析

    (一)为什么要用c++标准库里的排序函数 Sort()函数是c++一种排序方法之一,学会了这种方法也打消我学习c++以来使用的冒泡排序和选择排序所带来的执行效率不高的问题!因为它使用的排序方法是类似于 ...

  2. ServiceController组件控制计算机服务

    private void Form1_Load(object sender, EventArgs e) { //下面的示例使用 ServiceController 类检查IIS服务是否已停止.如果该服 ...

  3. This transaction has been rolled back, rather than only the current.

    今天上午,收到运维组同事反映某应用系统的其中一个功能报错,不是偶然性事件,每个使用该功能的用户都报错.报错内容为:This transaction has been rolled back, rath ...

  4. 移动端Reactive Native轮播组件

    移动端Reactive Native轮播组件 总结下这段时间学习reactive native的一些东西,我们来认识一下,被炒得这么火的rn,究竟是个什么东西,以及如何去搭建自己的demo. reac ...

  5. MacBookPro 蓝牙重置

    我的MBP经常休眠唤醒后蓝牙死机,怎么办? 大部分情况下,关机重启就可以了,但是如果还不行的话,试一下如下方法,也能解决问题: 重置一下电源管理和总线给你个方法 您的电脑首先是在关机的状态重置电源管理 ...

  6. Collection和Collections的区别

    Collection 是集合类的上级接口,继承它的接口主要有set和list.Collections 是针对集合类的一个帮助类,他提供一系列静态方法实现对各种集合的搜索,排序,线程安全化等操作.

  7. caffe之(四)全连接层

    在caffe中,网络的结构由prototxt文件中给出,由一些列的Layer(层)组成,常用的层如:数据加载层.卷积操作层.pooling层.非线性变换层.内积运算层.归一化层.损失计算层等:本篇主要 ...

  8. php和.net的DES加密解密方法

    .net版本 /// <summary> /// DES加密 /// </summary> /// <param name="pToEncrypt"& ...

  9. NGUI所见即所得之UIAtlasMaker , UIAtlas (2)

    本文的重点就是要将NGUI把多张图片打成一个图集(Atlas)的原理和过程研究下,学习下Unity提供的api和NGUI写的功能以及设计思想. (原文链接) 其它链接:NGUI所见即所得之UIRoot ...

  10. Altium Designer 特定网络取消 remove loops

    在使用Altium Designer时,在PCB Editor 里面可以设定是否需要Automatically remove Loops,但是这个设置是全局的,在设计时难免会遇到对大部分网络是需要删除 ...