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 ...
随机推荐
- C# 未能加载文件或程序集“MySQLDriverCS..." 错误解决
在解决方案的属性里,生成,里面有个目标平台,网上说的 大概也就是64位和32位的不兼容问题..试着把目标平台改为X86后竟然神奇的正常了!
- ASM丢失disk header导致ORA-15032、ORA-15040、ORA-15042 Diskgroup无法mount
SQL> select * from v$version; BANNER --------------------------– Oracle Database 11g Enterprise E ...
- linux脚本: makefile以及链接库
Linux makefile 教程 非常详细,且易懂 http://blog.csdn.net/liang13664759/article/details/1771246 //sort.c #incl ...
- 在Ubuntu 12.04下编译qtiplot
不在windows下,再加上不想用盗版,所以需要一个origin的替代品——qtiplot.虽然我非常抵抗用这种不停点来点去的软件,用R的ggplot2画图多好啊,高效.优雅.漂亮,但是终抵不过老板一 ...
- 为什么必须是final的呢?
一个谜团 如果你用过类似guava这种“伪函数式编程”风格的library的话,那下面这种风格的代码对你来说应该不陌生: 1 2 3 4 5 6 7 8 9 public void tryUsingG ...
- Swift - 给游戏添加背景音乐和音效(SpriteKit游戏开发)
游戏少不了背景音乐和音效.下面我们通过创建一个管理音效的类,来实现背景音乐的播放,同时点击屏幕可以播放相应的音效. 声音管理类 SoundManager.swift 1 2 3 4 5 6 7 8 9 ...
- python发送post和get请求
python发送post和get请求 get请求: 使用get方式时,请求数据直接放在url中. 方法一. import urllib import urllib2 url = "http: ...
- [WP8] Binding时,依照DataType来选择DataTemplate
原文 [WP8] Binding时,依照DataType来选择DataTemplate 范例下载 范例程序代码:点此下载 问题情景 在开发WPF.WP8...这类应用程序的时候,透过Binding机制 ...
- zabbix 获取jvm session信息
zabbix:/root# java -jar /root/cmdline-jmxclient-0.10.3.jar - 121x:5566 "Catalina:type=Manager,c ...
- 《Windows核心编程》第一讲 对程序错误的处理
一个Windows函数通常都有一个有意义的返回值类型,它标志着这个函数的运行状态,即函数运行成功与否.windows常用的函数类型如下图: 从系统内部来讲,当一个Windows函数检测到一个错误时,它 ...