題目鏈接:BestCoder Round #81 (div.2) 1003 String
中文題,上有鏈接,就不貼了。
枚舉起點i,計算可以達到k個不同字母的最小下標j,則此時有子串len-j個。
將所有起點的值加起來即是結果。
#include
#include
#include
using namespace std;
#define LL long long
const int MOD = 1000000007;
char str[1000009];
int num[27];
int get_cnt()
{
int cnt = 0;
for(int i=0; i<26; i++)
cnt += num[i]==0?0:1;
return cnt;
}
int main()
{
int T;
cin>>T;
while(T--)
{
int k;
memset(num, 0, sizeof(num));
scanf("%s%d", str, &k);
int len = strlen(str);
LL ans = 0;
int j = -1;
bool flag = false;
for(int i=0; i
相關文章
- Struts2 OGNL調用公共靜態方法詳細介紹
- BootStrap在jsp中的使用
- 詳解Hibernate cascade級聯屬性的CascadeType的用法
- 運用El表達式截取字符串/獲取list的長度實例
- struts json 類型異常返回到js彈框問題解決辦法
- Spring 整合 Hibernate 時啟用二級緩存實例詳解
- Spring框架中 @Autowired 和 @Resource 注解的區別
- Spring 中 @Service 和 @Resource 注解的區別
- 淺談request.getinputstream只能讀取一次的問題
- Spring mvc實現Restful返回xml格式數據實例詳解
閱讀排行榜
熱門圖文
Copyright © 程式師世界 All Rights Reserved