首页 > 其他 > 详细

HDU 5056 Boring count

时间:2014-10-14 16:58:30      阅读:119      评论:0      收藏:0      [点我收藏+]

题解:前缀和计算统计。

#include <cstdio>
#include <cstring>
using namespace std;
typedef long long LL;
LL ans; char s[100010];
int T,k,t[200],i,j,n;
int main(){
    scanf("%d",&T);
    while(T--){
        scanf("%s%d",s,&k);
        n=strlen(s);
        for(i=1;i<200;i++)t[i]=0;
        for(ans=i=j=0;i<n;i++){
            if(i)t[s[i-1]]--;
            while(j<n&&t[s[j]]<k)t[s[j++]]++;
            ans+=(LL)(j-i);
        }printf("%I64d\n",ans);
    }return 0;
}

HDU 5056 Boring count

原文:http://www.cnblogs.com/forever97/p/4024511.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!