题目链接: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的更多相关文章

  1. 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) ...

  2. HDU 5901 Count primes 论文题

    Count primes 题目连接: http://acm.split.hdu.edu.cn/showproblem.php?pid=5901 Description Easy question! C ...

  3. 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 ...

  4. HDU 6470 Count 【矩阵快速幂】(广东工业大学第十四届程序设计竞赛 )

    题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6470 Count Time Limit: 6000/3000 MS (Java/Others)    ...

  5. HDU 4372 Count the Buildings

    Count the Buildings Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Othe ...

  6. hdu 6016 Count the Sheep(思维)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6016 题意:给定男羊和女羊的朋友关系,即给定一个图,问从任意一只羊开始连续数四只不相同的羊的方法数. ...

  7. hdu 5901 count prime & code vs 3223 素数密度

    hdu5901题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5901 code vs 3223题目链接:http://codevs.cn/problem ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 好消息:8月25日广州嵌入式Linux开发免费项目约定你

    8月18日,粤嵌深圳分校举行了盛大的免费嵌入式项目体验,众多嵌入式爱好者排队参加项目体验的火爆场景仿佛还在眼前,体验效果得到学员一致好评.时隔一周,粤嵌广州总部也不容落后,在粤嵌广州总部举办<嵌 ...

  2. Winsock基础编程

    Winsock基础编程 Socket的英文原义是"孔"或"插座".作为BSD UNIX的进程通信机制,取后一种意思.通常也称作"套接字",用 ...

  3. hdu1370-Biorhythms

    http://acm.hdu.edu.cn/showproblem.php?pid=1370 中国剩余定理 已知(n+d)%23=a;   (n+d)%28=b;   (n+c)%33=i       ...

  4. spring 整合redis

    用的是最新的jedis-2.6.2.jar这个包,这个和以前的有点不同.还需要添加spring-data-redis-1.2.1.RELEASE.jar和commons-pool2-2.3.jar. ...

  5. 为什么java源文件中只允许一个public类存在

    1.提出问题 为什么java源文件中只允许一个public类存在? 2.分析问题 问题涉及到的条件:源文件的名字    public类     main方法 一般我们在编写一个源文件的时候: 一个pu ...

  6. Swift - 系统声音服务的使用(播放声音,提醒,震动)

    1,系统声音服务介绍: 系统声音服务提供了一个Api,用于播放不超过30秒的声音.它支持的文件格式有限,具体的说只有CAF.AIF和使用PCM或IMA/ADPCM数据的WAV文件. 但此函数没有提供操 ...

  7. Swift - 实现点击UITableView单元格时自动展开单元格

    下面是一个列表单元格cell的折叠展开效果的demo.当点击单元格时会展开该单元格,便于显示一些详情什么的.点击其他单元格原来的会关闭,同时有动画效果. 效果如如下:   代码如下: 1 2 3 4 ...

  8. struts2官方演示程序总结struts2-blank

    struts-2.2.3.1-all\struts-2.2.3.1\apps\struts2-blank总结 1.Html可以访问action  ,如下:    < head  >     ...

  9. NTP工作机制及时间同步的方法

    Network Time Protocol(NTP)是用来使计算机时间同步化的一种协议,它能够使计算机对其server或时钟源做同步化,它能够提供高精准度的时间校正,且可用加密确认的方式来防止恶毒的协 ...

  10. 在界面线程不能使用Sleep和WaitForSingleObject之类的函数, 使用 MsgWaitForMultipleObjects

    http://blog.csdn.net/wishfly/article/details/3726985 你在主线程用了WaitForSingleObject,导致了消息循环的阻塞,界面假死. 然后在 ...