Codeforces Round #226 (Div. 2)B. Bear and Strings
/*
题意就是要找到包含“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的更多相关文章
- Codeforces Round #226 (Div. 2)C. Bear and Prime Numbers
		
/* 可以在筛选质数的同时,算出每组数据中能被各个质数整除的个数, 然后算出[0,s]的个数 [l,r] 的个数即为[0,r]的个数减去[0,l]个数. */ #include <stdio.h ...
 - Codeforces Round #226 (Div. 2)A. Bear and Raspberry
		
/* 贪心的找到相邻两项差的最大值,再减去c,结果若是负数答案为0. */ 1 #include <stdio.h> #define maxn 105 int num[maxn]; int ...
 - 【计算几何】【状压dp】Codeforces Round #226 (Div. 2) D. Bear and Floodlight
		
读懂题意发现是傻逼状压. 只要会向量旋转,以及直线求交点坐标就行了.(验证了我这俩板子都没毛病) 细节蛮多. #include<cstdio> #include<algorithm& ...
 - 水题 Codeforces Round #302 (Div. 2) A Set of Strings
		
题目传送门 /* 题意:一个字符串分割成k段,每段开头字母不相同 水题:记录每个字母出现的次数,每一次分割把首字母的次数降为0,最后一段直接全部输出 */ #include <cstdio> ...
 - Codeforces Round #226 (Div. 2) B
		
B. Bear and Strings time limit per test 1 second memory limit per test 256 megabytes input standard ...
 - 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 ...
 - 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 ...
 - 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 ...
 - 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 ...
 
随机推荐
- hdu 2594 Simpsons’ Hidden Talents   KMP应用
			
Simpsons’ Hidden Talents Problem Description Write a program that, when given strings s1 and s2, fin ...
 - 【java】Servlet 工程 web.xml 中的 servlet 和 servlet-mapping 标签
			
摘录某个工程的 web.xml 文件片段: 访问顺序为1—>2—>3—>4,其中2和3的值必须相同. url-pattern 标签中的值是要在浏览器地址栏中输入的 url,可以自己命 ...
 - jquery方法的参数解读
			
18:22 2013/9/21 attr(name|properties|key,value|fn) 概述 设置或返回被选元素的属性值. 在jquery中[]表示可选参数,你可以不选,| 表示参数可以 ...
 - python xlrd,xlwt 读写excel文件
			
python 读excel文件,需要xlrd库.下载地址:https://pypi.python.org/pypi/xlrd python 写excel文件,需要xlwt库.下载地址:https:// ...
 - Python标准库与第三方库详解(转载)
			
转载地址: http://www.codeweblog.com/python%e6%a0%87%e5%87%86%e5%ba%93%e4%b8%8e%e7%ac%ac%e4%b8%89%e6%96%b ...
 - Centos安装gnome主菜单编辑器无
			
首选项---主菜单-- 即是alacarte.. centos ===安装 alacarte.noarch 0:0.12.4-1.el6 即可.
 - c++ 类的对象与指针
			
这里首先我们需区分一下指针数组和数组指针. 指针数组:int *p[4];它最终是个数组,只是这个数组存储的是4个指向int类型的指针. 数组指针:int (*P)[4];它最终是个指针,表示一个指向 ...
 - BZOJ 3715: [PA2014]Lustra
			
Description Byteasar公司专门外包生产带有镜子的衣柜.刚刚举行的招标会上,有n个工厂参加竞标.所有镜子都是长方形的,每个工厂能够制造的镜子都有其各自的最大.最小宽度和最大.最小高度. ...
 - 1006: [HNOI2008]神奇的国度
			
图上的最小的染色方案: 学习了陈丹绮的论文: MCS算法 #include<cstdio> #define maxn 10005 #define maxm 2000005 using na ...
 - 通过调用门进行有特权级变换的转移,详细注解  对pmtest5.asm解释很详细.
			
http://www.myexception.cn/operating-system/484288.html http://www.myexception.cn/operating-system/44 ...