hdu 5056Boring count
题目链接:http://acm.hdu.edu.cn/showproblem.php?
pid=5056
题目大意:就是问在子串中每一个小写字母出现次数不超过k次的个数,注意子串是连续的子串。。
。
。
思路:
code:
<span style="font-size:18px;">#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm> using namespace std; char str[100010];
int cnt[30];
int main()
{
int T,k,i;
scanf("%d",&T);
while(T--)
{
memset(str,0,sizeof(str));
memset(cnt,0,sizeof(cnt));
scanf("%s%d",str,&k);
int len=strlen(str);
int starPos=0;
__int64 ans=0;
for(i=0;i<len;i++)
{
cnt[str[i]-'a']++;
if(cnt[str[i]-'a']>k)
{
while(str[starPos]!=str[i])
{
cnt[str[starPos]-'a']--;
starPos++;
}
cnt[str[starPos]-'a']--;
starPos++;
}
printf("AAA %d %d\n",i,starPos);
ans+=(i-starPos+1);
}
printf("%I64d\n",ans);
}
return 0;
}
</span>
hdu 5056Boring count的更多相关文章
- HDU 3336 Count the string(KMP的Next数组应用+DP)
Count the string Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU 5901 Count primes 论文题
Count primes 题目连接: http://acm.split.hdu.edu.cn/showproblem.php?pid=5901 Description Easy question! C ...
- hdu 3336 Count the string -KMP&dp
It is well known that AekdyCoin is good at string problems as well as number theory problems. When g ...
- HDU 6470 Count 【矩阵快速幂】(广东工业大学第十四届程序设计竞赛 )
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6470 Count Time Limit: 6000/3000 MS (Java/Others) ...
- HDU 4372 Count the Buildings
Count the Buildings Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- hdu 6016 Count the Sheep(思维)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6016 题意:给定男羊和女羊的朋友关系,即给定一个图,问从任意一只羊开始连续数四只不相同的羊的方法数. ...
- hdu 5901 count prime & code vs 3223 素数密度
hdu5901题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5901 code vs 3223题目链接:http://codevs.cn/problem ...
- leetcode N-Queens/N-Queens II, backtracking, hdu 2553 count N-Queens, dfs 分类: leetcode hdoj 2015-07-09 02:07 102人阅读 评论(0) 收藏
for the backtracking part, thanks to the video of stanford cs106b lecture 10 by Julie Zelenski for t ...
- 2015ACM/ICPC亚洲区长春站 B hdu 5528 Count a * b
Count a * b Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Tot ...
随机推荐
- linux下crontab的使用方法
<span style="font-size:14px;">在Linux中任务可以被配置在指定的时间段.指定的日期.或系统平均载量低于指定的数量时自动运行. cront ...
- Swift初体验 (一)
// 声明一个常量 let maxNumberOfStudents: Int = 47 // 声明一个变量,假设没有在声明的时候初始化,须要显示的标注其类型 var currentNumberOfSt ...
- 鼠标进入与离开的消息(使用CM_MOUSEENTER来判断是否进入控件)
unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs ...
- MYSQL查询表结构
mysql查看表结构命令,如下: desc 表名;show columns from 表名;describe 表名;show create table 表名; use information_sche ...
- oracle 的常用语句
第一部分 基本语法 //拼接表字段 select id || 'is' || name from admin select * from emp where ename like '% ...
- HDU ACM 1081 To The Max->最大子矩阵
分析:利用求最大子段和的思想进行求解. 1.首先累加s[i][j].表示第j列中i从第1行加到第i行的和. 2.对每一列的i1到i2行的和进行计算(0<i1<i2<=n),得出t[k ...
- Servlet的学习之Request请求对象(1)
在本篇中开始对Servlet中的HttpServletRequest请求对象进行学习,请求对象同响应对象一样,我们可以根据该对象中的方法获取例如请求行,请求头和请求实体数据的方法. 在本篇中先对Htt ...
- Convert QWERTY to Dvorak
Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Submit Status Pract ...
- CEdit 样式与消息 解析
编辑框(Edit)控件实际上是一个简易的文本编辑器,用户可以在编辑框中输入可添加或插入文本.还有复制.粘贴.剪切.删除等编辑功能. 应用程序用CreateWindowEx创建编辑框控件时,可根据控件的 ...
- 通过程序预览Office文档
我承认,标题是夸大了,就是为了吸引注意力.这里只有Word文档和Excel文档的预览代码. Word://此部分来源:http://princed.mblogger.cn/posts/11885.as ...