
Rabin Karp
文章平均质量分 77
Benzema67
北京邮电大学学生
展开
-
HDU 3973 AC's String
<!-- @page {margin:0.79in} p {margin-bottom:0.08in; direction:ltr; color:#000000; text-align:justify; widows:0; orphans:0} p.western {font-family:"Calibri",sans-serif; font-size:1原创 2012-09-05 15:02:38 · 2321 阅读 · 3 评论 -
Codeforces 213E - Two Permutations
用线段树维护一段序列的HASH值 #include #include #define N 200010 #define M 1000003 //prime #define Mod 1000000007 //prime typedef long long ll; using namespace std; ll tem[N],sum,s; int num[N],pos[N]; struct T原创 2012-08-19 23:35:08 · 1450 阅读 · 0 评论 -
Codeforces Beta Round #7, problem: (D) Palindrome Degree
#include #include #include #include __int64 dp[5000000+5]; char s[5000000+5]; using namespace std; int main(void) { __int64 ans=0,l=0,r=0,k=1; scanf("%s",s); for(int i=0;s[i];i++) {原创 2012-09-05 15:21:25 · 1586 阅读 · 0 评论 -
HDU 4339
常规做法大家应该都会了,这里说一下hash的做法 (摘自官方解题报告) We can compare two substrings using hash (s[0]*(p^0)+s[1]*(p^1)+...+s[i]*(p^i), where ^ means power). Let's n be 1+max(l1, l2). For i (l1<=i and i<n) put s原创 2012-09-15 22:21:28 · 864 阅读 · 0 评论 -
CF 113B || CF196D
watashi大神的代码 #include #include #include #include using namespace std; vector pos(const string& s, const string& p) { vector ret; for (string::size_type i = s.find(p); i != string::npos; i =原创 2012-09-05 13:42:26 · 1256 阅读 · 0 评论 -
SPOJ HACKING
题意:给出一个长为 n 的,由字母表中前 k 个小写字母组成的字符串 s.求一个长度为m的字符串,要求该串也只能由字母表前 k 个小写字母组成,且其不能是 s 的子串. (题目指出一定有解) 方法一:在判重时采用这样的方法,想把原串中长度为m1的字串都求出hash值存入set中,然后从0开始寻找第一个未出现在set中的数,将其翻译成相应的字符串. #include #include原创 2012-09-05 13:38:42 · 777 阅读 · 0 评论 -
Codeforces Round #166 (Div. 2) D - Good Substrings
题意说的很清楚了,就是要寻找满足某一条件的不同字串个数。 方法一: 寻找不同字串个数体型很直接的一种方法就是把字符串hash值保存在set或者数组中,统计其中不同的个数。 //一个长为n的字符串的字串个数为n*(n+1)/2 #include #include #include #include #include #define multiple 1000000007 //这里mul原创 2013-02-13 00:18:01 · 1529 阅读 · 0 评论