题目链接: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. JCL学习

    JCL基本概念 定义:job control language 用户与操作系统的接口,用户通过JCL语句按照自己的意图来控制作业的执行. JOB的概念:把大机要实现的每一项任务,称为一个JOB或作业. ...

  2. URAL 1707. Hypnotoad&#39;s Secret(树阵)

    URAL 1707. Hypnotoad's Secret space=1&num=1707" target="_blank" style="" ...

  3. ActivityManager

    android.app.ActivityManager 这个类主要用来管理全部设备上的Activities. 权限:android.permission.GET_TASKS 方法:| 返回类型     ...

  4. 配置rhel 6.4(64位)安装使用syslog-ng 3.5

    我基本的博客地址是:www.cppblog.com/zdhsoft 相应的CentOS 6.x也就可能使用. 下载地址: 第一步:安装 wget http://www.balabit.com/down ...

  5. 利用VS2005进行dump文件调试(17篇博客)

    前言:利用drwtsn32或NTSD进行程序崩溃处理,都可以生成可用于调试的dmp格式文件.使用VS2005打开生成的DMP文件,能很方便的找出BUG所在位置.本文将讨论以下内容: 1.  程序编译选 ...

  6. 聊天气泡的绘制(圆角矩形+三角形+黑色边框,关键学会QPainter的draw函数就行了),注意每个QLabel都有自己的独立坐标

    头文件: #ifndef GLABEL_H #define GLABEL_H #include <QLabel> #include <QPainter> #include &l ...

  7. MapReduce调度与执行原理之作业提交

    前言 :本文旨在理清在Hadoop中一个MapReduce作业(Job)在提交到框架后的整个生命周期过程,权作总结和日后参考,如有问题,请不吝赐教.本文不涉及Hadoop的架构设计,如有兴趣请参考相关 ...

  8. 基于visual Studio2013解决C语言竞赛题之1053洗牌

       题目 解决代码及点评 /* 功能:洗扑克牌.将54张牌分别编号为1,2,-,54号,并放在数组M中. 洗牌方法如下:产生[1,54]区间内的一个随机数K,将M[1]与M[K]交换: ...

  9. 微软推荐的130道ASP.NET常见面试题及答案

    1. 简述 private. protected. public. internal 修饰符的访问权限. 答 . private : 私有成员, 在类的内部才可以访问. protected : 保护成 ...

  10. JQuery - 垂直显示隐藏DIV

    效果: 代码: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebFor ...