题目链接

字符串hash判断字符串是否相等。

code

 #include<cstdio>
#include<algorithm>
#include<cstring> using namespace std; typedef unsigned long long uLL;
const uLL B = ; uLL f[];
uLL Hash[];
char a[],b[]; int main () {
int T;
scanf("%d",&T);
f[] = ;
for (int i=; i<=; ++i) f[i] = (f[i-] * B);
while (T--) {
int ans = ;
scanf("%s%s",a,b);
int s1 = strlen(a),s2 = strlen(b);
uLL Ha = ;
for (int i=; i<s1; ++i) {
Ha = (Ha*B+a[i]);
}
Hash[] = b[];
for (int i=; i<s2; ++i) {
Hash[i] = Hash[i-]*B+b[i];
}
for (int i=; i<=(s2-s1); ++i) {
int l = i,r = l+s1-;
uLL Hb = Hash[r]-Hash[l-]*f[s1];
if (Ha == Hb) ans++;
}
printf("%d\n",ans);
}
return ;
}

POJ 3461 Oulipo(字符串hash)的更多相关文章

  1. POJ 3461 Oulipo(乌力波)

    POJ 3461 Oulipo(乌力波) Time Limit: 1000MS   Memory Limit: 65536K [Description] [题目描述] The French autho ...

  2. HDU 1686 Oulipo / POJ 3461 Oulipo / SCU 2652 Oulipo (字符串匹配,KMP)

    HDU 1686 Oulipo / POJ 3461 Oulipo / SCU 2652 Oulipo (字符串匹配,KMP) Description The French author George ...

  3. 字符串hash - POJ 3461 Oulipo

    Oulipo Problem's Link ---------------------------------------------------------------------------- M ...

  4. POJ 3461 Oulipo

      E - Oulipo Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit ...

  5. POJ 3865 - Database 字符串hash

    [题意] 给一个字符串组成的矩阵,规模为n*m(n<=10000,m<=10),如果某两列中存在两行完全相同,则输出NO和两行行号和两列列号,否则输出YES [题解] 因为m很小,所以对每 ...

  6. POJ 3461 Oulipo[附KMP算法详细流程讲解]

      E - Oulipo Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit ...

  7. POJ 3461 Oulipo 【KMP统计子串数】

    传送门:http://poj.org/problem?id=3461 Oulipo Time Limit: 1000MS   Memory Limit: 65536K Total Submission ...

  8. Palindrome POJ - 3974 (字符串hash+二分)

    Andy the smart computer science student was attending an algorithms class when the professor asked t ...

  9. POJ 3461 Oulipo(模式串在主串中出现的次数)

    题目链接:http://poj.org/problem?id=3461 题意:给你两个字符串word和text,求出word在text中出现的次数 思路:kmp算法的简单应用,遍历一遍text字符串即 ...

随机推荐

  1. System Center Configuration Manager 2016 配置安装篇(Part1)

    SCCM 2016 配置管理系列(Part 1- 4) 介绍AD01上配置了Active Directory域服务(ADDS),然后将Configuration Manager服务器(CM16)加入到 ...

  2. 使用ajax实现简单的带百分比进度条

    需求:当进行文件上传保存等操作时,能在页面显示一个带百分比的进度条,给用户一个好的交互体验 实现步骤 JSP页面 1.添加table标签 <table id="load" w ...

  3. centos6.5_64bit-Tomcat7安装部署

    此次安装系统版本及软件版本 centos6.5-64bit java -1.7.0_45 jdk1.8.0_111 apache-tomcat-7.0.73   一.检查java版本信息        ...

  4. iOS获取/删除url中的参数

    1.获取URL中的某个参数: - (NSString *)getParameter:(NSString *)parameter urlStr:(NSString *)url { NSError *er ...

  5. 16 Javascript

    网上找网页模板: 1.HTML模板 2.BootStrap 前面内容总结 HTML 标签:块级,行内 CSS 后台管理布局 position: fixed  ---永远固定在窗口的某个位置 relat ...

  6. Linux终端(terminal)清屏命令

    windows CMD终端的清屏命令是cls Linux终端中的清屏命令有 1) clear 2) reset

  7. 永恒之蓝EternalBlue复现

    0x01 漏洞原理:http://blogs.360.cn/blog/nsa-eternalblue-smb/ 目前已知受影响的 Windows 版本包括但不限于:Windows NT,Windows ...

  8. 快速提取邮箱地址(利用word或网站)

    在word中,CTRL+F,输入:[A-z,0-9]{1,}\@[A-z,0-9,\.]{1,} 点击“高级”,勾选“使用通配符”,点击“查找全部”: 复制.粘贴. 还可通过以下页面在线提取. htt ...

  9. 虚拟内存映射 段分割 vm_area_struct

    http://www.cnblogs.com/huxiao-tee/p/4660352.html linux内核使用vm_area_struct结构来表示一个独立的虚拟内存区域,由于每个不同质的虚拟内 ...

  10. uva题库爬取

    每次进uva都慢的要死,而且一步一步找到自己的那个题目简直要命. 于是,我想到做一个爬取uva题库,记录一下其中遇到的问题. 1.uva题目的链接是一个外部的,想要获取https资源,会报出SNIMi ...