P3370 【模板】字符串哈希 · znzryb
## 思路讲解
## AC代码
```cpp
#include <iostream>
#include <cstring>
#include <algorithm>
#include <deque>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <bitset>
#include <iterator>
#include <random>
#include <iomanip>
#include <cctype>
#include <array>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef array<ll,3> arr;
const ll MAXN=static_cast<ll>(1e6)+19;
const ll mod=static_cast<ll>(1e18)+3,base=114;
ll N;
ll myhash[MAXN];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>N;
for(int i=0;i<N;++i){
string s;
cin>>s;
ll val=0;
for(int j=0;j<s.size();++j){
val=(s[j]+val*base)%mod;
}
myhash[i]=val;
}
sort(myhash, myhash+N);
ll ans=0;
myhash[N]=-1;
for(int i=0;i<N;++i){
if(myhash[i]!=myhash[i+1]){
++ans;
}
}
cout<<ans<<'\n';
return 0;
}
// AC https://www.luogu.com.cn/record/198474085
```
## 心路历程(WA,TLE,MLE……)