string
来源:互联网 发布:微信刷赞软件破解版 编辑:程序博客网 时间:2024/06/07 23:17
Boring count
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1659 Accepted Submission(s): 611
Problem Description
You are given a string S consisting of lowercase letters, and your task is counting the number of substring that the number of each lowercase letter in the substring is no more than K.
Input
In the first line there is an integer T , indicates the number of test cases.
For each case, the first line contains a string which only consist of lowercase letters. The second line contains an integer K.
[Technical Specification]
1<=T<= 100
1 <= the length of S <= 100000
1 <= K <= 100000
For each case, the first line contains a string which only consist of lowercase letters. The second line contains an integer K.
[Technical Specification]
1<=T<= 100
1 <= the length of S <= 100000
1 <= K <= 100000
Output
For each case, output a line contains the answer.
Sample Input
3abc1abcabc1abcabc2
Sample Output
61521
#include<iostream>#include<string.h>using namespace std;char s[100005];int flag[100005];int main(){int t;cin>>t;while(t--){memset(flag,0,sizeof(flag));int pos=0,k,i,j;long long count=0;cin>>s;cin>>k;for(i=0;s[i]!='\0';i++){flag[s[i]-'a']++;if(flag[s[i]-'a']>k){while(s[pos]!=s[i]){flag[s[pos]-'a']--;pos++;}flag[s[pos]-'a']--;pos++;}count+=i+1-pos;}cout<<count<<endl;}}
阅读全文
0 0
- string
- String
- String
- string
- string
- String
- string
- String
- string
- string
- string
- string
- String
- String
- string
- string +
- String
- String
- ubuntu14.04图形界面突然进不去
- 字幕字体滚动插件——scroxt.js
- 天天学Linux命令51--date命令
- 资源
- Unit8
- string
- TMMi如何促进软件测试过程的改进
- 用程序来控制一个网页,实现自动输入等操作
- 【bzoj1090】[SCOI2003]字符串折叠
- 最短路—Floyd(QAQ)
- 如何搭建健身房教练私教器材设备微信公众号预约系统
- 将MongoDB的数据提取出来并转到MySQL遇到的问题
- centos7安装samba
- Oracle数据库之ROWID伪列