题目大意:给出一个匹配串S和一个字符串T,问匹配串在字符串中出现了几次 经典的字符串匹配问题,可以用KMP,BM,Sunday等各种方法解决,但是我觉得字符串哈希才是最好写最好理解的。。 先将匹配串hash一遍 然后从字符串的第一位开始,判断第i位和匹配串的第一位是否相同,相同的话对字符串的第i到第i+strlen(s)-1位hash,看哈希值是否相同 相同的话ans++

#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<sstream>
#include<stack>
#include<set>
#include<bitset>
#include<vector>
using namespace std;
#define ull unsigned long long

#define  LL long long
const int maxn=1000010;
ull base =131;

char S[maxn];
char T[maxn];
ull g[maxn];
ull p[maxn];

ull Hash(char s[])
{
    int len=strlen(s);
    ull ans=0;

    g[0]=s[0];
    for(int i=1;i</vector></bitset></set></stack></sstream></queue></map></cmath></cstring></cstdio>