hdu 5056
来源:互联网 发布:淘宝开放平台的api 编辑:程序博客网 时间:2024/06/06 14:20
题目链接
题目大意:计算在子串中每个小写字母出现次数不超过k次的个数
官方题解:
#include<iostream>#include<cmath>#include<cstring>#include<algorithm>#include<stdio.h>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++; } ans+=(i-starPos+1); } printf("%I64d\n",ans); } return 0;}
参考博客一
参考博客二
参考博客三
搜索
复制
0 0
- hdu 5056
- hdu 5056
- HDU 5056 - Boring count
- hdu 5056Boring count
- hdu 5056 Boring count
- hdu 5056 Boring Counts
- hdu 5056 Boring count
- HDU 5056 字符串处理
- HDU 5056Boring count
- hdu 5056(尺取法)
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- Go语言文档
- 【Java GUI】Java GUI基础
- javaScript中私有属性和方法
- Android.mk文件语法规范及使用模板
- Tcp客户端并发登录
- hdu 5056
- POJ - 1979 Red and Black
- Unity3D添加天空盒
- 初涉云计算——从Google三大论文说起
- IOS 中什么时候使用copy
- swing做的俄罗斯方块
- 让Souce Insight支持多种语言的语法高亮:Python,Ruby,ARM汇编,windows脚本文件(bat/batch),PPC,SQL,TCL,Delphi等
- UVa第五章STL应用 习题((解题报告))详细!
- 你是如何拿到阿里巴巴,百度,腾讯的前端实习生offer的?