社区讨论
63pts求助,WA on #7#9 #10 #11
P3370【模板】字符串哈希参与者 2已保存回复 1
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 1 条
- 当前快照
- 1 份
- 快照标识符
- @mhj1ilho
- 此快照首次捕获于
- 2025/11/03 19:11 4 个月前
- 此快照最后确认于
- 2025/11/03 19:11 4 个月前
CPP
#include <bits/stdc++.h>
using namespace std;
const int mod=999983;
bool a[mod+2];
char c[1510];
int stringtoint(string s){
long long int hash=1,base=133;
for(int i=0;i<s.length();i++){
hash=(hash*base*1111+(int)s[i])%mod;
}
return hash;
}
int main()
{
int n,hash=1,ans=0;
char c;
cin >> n;
for(int i=1;i<=n;i++)
{
string s;
cin>>s;
hash=stringtoint(s);
if(!a[hash]){
a[hash]=1;
ans++;
}
}
cout << ans;
}
回复
共 1 条回复,欢迎继续交流。
正在加载回复...