CE求调

P3370 【模板】字符串哈希

函数名有问题,hash改成myhash即可
by Lunar_Hjj @ 2023-07-20 16:41:03


@[lcy12](/user/615490) hash是关键字,不能用来做函数名
by Creeper_l @ 2023-07-20 16:41:17


[评测记录](https://www.luogu.com.cn/record/116612079) ```cpp #include<bits/stdc++.h> #define int long long #define base 131 #define PRIME 233317 using namespace std; unsigned long long mod=212370440130137957; int n,a[100005],ans=1; string s; int myhash(string s) { int y=s.size(); int sum=0; for(int i=0;i<y;i++) sum=(sum*base+(int)s[i])%mod+PRIME; return sum; } signed main() { cin>>n; for(int i=1;i<=n;i++) { cin>>s; a[i]=myhash(s); } sort(a+1,a+n+1); for(int i=2;i<=n;i++) if(a[i]!=a[i-1]) ans++; cout<<ans; } ```
by Lunar_Hjj @ 2023-07-20 16:41:49


懂力,谢谢s组dalao们
by lcy_123 @ 2023-07-20 16:43:36


|