#include <iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stdbool.h>
using namespace std;
#define ll long long
const int p=10e7+7;
const int mod=10e9+9;
int n;
string s[110];
int h[110][260];
string result;
int main()
{
freopen("d://jin.txt","r",stdin);
cin>>n;
getchar();
for(int i=0; i<n; i++)
{
getline(cin,s[i]);
if(i==0)result=s[0];
h[i][s[i].length()]=0;
int l=s[i].length()-1;
for(int j=0; j<min(s[i].length(),result.length()); j++)
{
h[i][l-j]=(h[i][l-j+1]*p+s[i][l-j]-'a')%mod;
if(h[i][l-j]==h[0][s[0].length()-1-j])
continue;
else
{
result=s[i].substr(l-j+1);
break;
}
}
}
if(result!="")
cout<<result<<endl;
else cout<<"nai"<<endl;
return 0;
}
1077. Kuchiguse 字符串hash
最新推荐文章于 2020-01-02 15:01:11 发布