字符串哈希
来源:互联网 发布:西安历史气象数据查询 编辑:程序博客网 时间:2024/05/18 01:42
#include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#define ull unsigned long longconst ull B=1e8+7;char s[1000],s1[1000];int hash_find(char *a,char *b){ull i,j,k,m,n,al=0,bl=0,x,y,t=1;x=strlen(a);y=strlen(b);if (x>y) return -1;for (i=0;i<x;i++){t*=B;al=al*B+a[i];bl=bl*B+b[i];}for (i=0;i+x<=y;i++){if (al==bl) return i;if (i+x<y) bl=bl*B-b[i]*t+b[i+x];}return -1;}int main(){int i,j,k,m,n;gets(s1);gets(s);printf("%d\n",hash_find(s1,s));return 0;}
0 0
- FZU 2137 奇异字符串 字符串哈希
- 字符串哈希函数
- 字符串哈希
- 字符串哈希函数
- 字符串哈希函数
- 生成哈希字符串
- 字符串哈希函数
- 字符串哈希函数
- hdu2920 字符串哈希
- 字符串哈希算法
- POJ3461 字符串哈希
- 字符串哈希函数
- 字符串哈希函数
- 字符串哈希函数
- hdu4821 字符串哈希
- 字符串哈希函数
- 字符串哈希函数
- 字符串哈希函数
- Java程序员必读的11本书
- myeclipse做SSM项目插数据到mysql,有中文会出现乱码
- lintcode- k数和II-90
- HDU 1003 区间最大和问题(动态规划)
- 关于abc全排列的方法
- 字符串哈希
- 编程的方式操作IIS 参考文档
- 绑定数据 Repeater 与ObjectDataSource的用法
- 红黑树增加新节点
- javascript函数的3种定义方式
- Rqnoj 题目 72拔河比赛 (01背包)
- does not have write access to 'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET File
- UVA - 10340 All in All
- 高精度乘法(压位)