博主链接
##题目链接:

题意:

一堆士兵学骑扫把,高级士兵可以教低级士兵,并且共用一个扫把,一个老师只能有一个学生,这个关系可以传递的,例如等级A>B>C>D>F>E,则A可以教B、B可以教C、…,那么ABCDEF共用一个扫把.
给出所有士兵的等级,求最少要多少个扫把。

题解:

可以看得出扫把的数量就是某个最多人的等级中的人数,那么就是简单的hash了,对应的关系是
hash【等级】 = 人数
求最大人数

代码:

#include<stdio.h>
#include<bits/stdc++.h>
#define ll long long int
#define met(a) memset(a,0,sizeof(a))
#define fup(i,a,n,b) for(int i=a;i<n;i+=b)
#define fow(j,a,n,b) for(int j=a;j>0;j-=b)
#define MOD(x) (x)%mod
using namespace std;
const int maxn = 1e6 + 5;
char s[100];
ll H[maxn];
void Hash_(char * s, int cnt,int m) {
	ll h=0;
	int i = 0;
	while (s[i] == '0')i++;
	for ( i ; s[i]; i++)
		h = ((h << 8) + s[i])%m;
	H[cnt] = h;
}
int main() {
	int n;
	while (scanf("%d", &n) != EOF) {
		for (int i = 0; i < n; i++) {
			scanf("%s",s);
			Hash_(s, i,1e9+7);
		}
		sort(H, H + n);
		int ans = 1,cnt=0;
		for (int i = 1; i < n; i++) {
			if (H[i] == H[i - 1]) {
				ans++;
				continue;
			}
			else {
				cnt = max(cnt, ans);
				ans = 1;
			}
		}
		cnt = max(ans, cnt);
		printf("%d\n", cnt);
	}
}