题目链接: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. 微软Ajax--UpdatePanel控件

    今天用做日历显示本月的考勤记录,用到了UpdatePanel控件,才发现对这个控件并不太了解,所以找了点儿资料,整理了一下给大家发上来! 一.UpdatePanel的结构 <asp:Script ...

  2. EasyUI - DataGrid 组建 - [ 搜索功能 ]

    效果: html代码: 使用css加载的方式,所以要在写html代码,也可以使用js操作. <div> <!--使用JS加载方式--> <table id="t ...

  3. 摘记:IIS长时间任务超时处理

    1.如果是在客户端调用Webservice,首先设置客户端超时, SoapHttpClientProtocol.Timeout = 3600 * 1000;//单位为秒,这是设置了一个小时 2.如果站 ...

  4. 围观M$的new

    围观M$的new 对于new一个类, M$为了拷贝和移动时的效率问题, 使用了非标准的new语法, 为了兼容性, 只能围观. http://blog.csdn.net/lostspeed/articl ...

  5. MFC模板CArray及其派生类

    CArray及其派生类 1. 简介:访问方法及效率和普通的数组一样,比普通数组强大的功能是可以改变数组的大小.Array采用队列方式存储数据,因而其内部数据元素是以物理方式顺序排列的,所以检索.顺序执 ...

  6. MSSQL- select @@identity的用法

    转载自:http://blog.163.com/zhangqian_sms/blog/static/544483382008925112539620/ 用select @@identity得到上一次插 ...

  7. Appium Server 传递的基本参数

    Appium Server  传递的基本参数 官方列表 Appium server capabilities Capability Description Values automationName ...

  8. 【ASP.NET Web API教程】3 Web API客户端

    原文:[ASP.NET Web API教程]3 Web API客户端 Chapter 3: Web API Clients 第3章 Web API客户端 本文引自:http://www.asp.net ...

  9. haproxy redirect location和redirect prefix

    <pre name="code" class="html">redirect location <loc> [code <code ...

  10. POJ 1781 In Danger Joseph环 位运算解法

    Joseph环,这次模固定是2.假设不是固定模2,那么一般时间效率是O(n).可是这次由于固定模2,那么能够利用2的特殊性,把时间效率提高到O(1). 规律能够看下图: watermark/2/tex ...