社区讨论

输出0!!! 求条

P3370【模板】字符串哈希参与者 3已保存回复 3

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
3 条
当前快照
1 份
快照标识符
@m1rq8dvi
此快照首次捕获于
2024/10/02 18:30
去年
此快照最后确认于
2025/11/04 18:17
4 个月前
查看原帖
CPP
#include <bits/stdc++.h>
using namespace std;

string a;
int n;
int cnt;
int c[10010];

int hash(string k){
	int t = 0;
	for(int i = 0; i < k.size(); i++){
		t += k[i] % 5 * 56 % 4 & 5;
	}
	return t;
}

int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a;
		c[i] = hash(a);
	}
	sort(c + 1,c + n + 1);
	for(int i = 1; i < n; i++){
		if(c[i] != c[i + 1]) cnt ++;
	}
	cout << cnt;
	return 0;
}

回复

3 条回复,欢迎继续交流。

正在加载回复...