CF271 D 字符串hash
来源:互联网 发布:jsp 收费系统 源码 编辑:程序博客网 时间:2024/05/01 14:49
题意:求不被认同的字符串使用不超过k次的子串的个数
解法:直接取一个素数对字符串hash然后扔进set里面就可以了 string真的不行 太慢了
#include<set>#include<map>#include<cstdio>#include<iostream>#include<string.h>using namespace std;#define maxn 11111#define mul 1000000007#define ll long longchar s[maxn],ss[maxn];int k;set<ll>se;int main(){ scanf("%s%s%d",s,ss,&k); string sd;int cnt;ll id; int l=(int)strlen(s); for(int i=0;i<l;++i){ cnt=0;id=(ll)0; for(int j=i;j<l;++j){ id=id*mul+s[j]; cnt+=ss[s[j]-'a']=='0'; if(cnt>k)break; se.insert(id); } } // for(set<int>::iterator it=se.begin();it!=se.end();++it){// printf("%d\n",*it);// } int ans=(int)se.size(); printf("%d\n",ans); return 0;}
0 0
- CF271 D 字符串hash
- codeforces 7D Palindrome Degree 字符串hash
- CodeForces 7D Palindrome Degree 字符串hash
- CF 835D D. Palindromic characteristics 字符串hash
- Codeforces round 244(div.2) D match&catch【字符串hash】
- 【字符串hash】 codeforces 471D MUH and Cube Walls
- Codeforces 7D Palindrome Degree 字符串hash DP
- CF D. DZY Loves Strings(字符串hash 暴力)
- 字符串hash
- 字符串HASH
- 字符串Hash
- 字符串hash
- 字符串hash
- 字符串hash
- 字符串Hash
- 字符串hash
- 字符串hash
- 字符串 HASH
- android的一段混音代码
- 数据挖掘学科发展报告
- NameValueCollection类集合
- 20140909
- 该日期是该年第几天
- CF271 D 字符串hash
- linux关闭防火墙
- 【codeforces】 464B Restore Cube
- Array(数组)与Json String (Json字符串) 的相互转换
- 打造自己的js库1 -- 脚本动态加载
- 精读《JAVAScript高级程序设计》笔记(一)——基本概念
- exact nn search in hamming space
- JSChart_页面图形报表
- HDU1060 Leftmost Digit