哈希字符串又炸了
#include<bits/stdc++.h>
using namespace std;
char c='0';
long long a,b,poi,tpoi=-1,num;
bool bo;
string s1,s2;
int main()
{
getline(cin,s1); getline(cin,s2);
for(register int i=0;i<s1.size();++i)
{
c=s1[i];
if(c>'Z')
a=(a*31+(c-'a'))%1000000007;
else
a=(a*31+(c-'A'))%1000000007;
}
for(register int i=0;i<s2.size();++i)
{
c=s2[i];
if(c==' ')
{
if(a==b)
{
++num;
if(!bo)
{
bo=true;
poi=tpoi;
}
}
b=0;
while(c==' ')
{
++i;
c=s2[i];
}
}
else
{
if(c>'Z')
b=(b*31+(c-'a'))%1000000007;
else
b=(b*31+(c-'A'))%1000000007;
}
++tpoi;
}
if(a==b)
{
++num;
if(!bo)
{
bo=true;
poi=tpoi;
}
}
if(bo) cout<<num<<" "<<poi;
else cout<<"-1";
return 0;
}
回帖请私信@Rosmontis_
本人昨天把这位jc了,导致这位爷被禁言QwQ