Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

不知道哪里错了。。。。。。有dalao麻烦帮忙看一下

Posted by lvweihua at 2017-08-15 13:51:17 on Problem 3640
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int MAXN = 10005;
const int MAXM = 10000007;
const int B = 47;
int num[MAXN][4], stu[MAXM], N;
char str[MAXN][15];
int Hash(char s[]) {
	int res = 0;
	for (int i = 0; i<15; i++) {
		res = (s[i] - '0' + res*B) % MAXM;
	}
	return res;
}
int main() {
	while (scanf("%d", &N) && N) {
		memset(stu, 0, sizeof(stu));
		for (int i = 0; i<N; i++) {
			for (int j = 0; j<5; j++)
				scanf("%d", &num[i][j]);
			sort(num[i], num[i] + 5);
			for (int j = 0; j<5; j++)
				sprintf(&str[i][j * 3], "%d", num[i][j]);
			stu[i] = Hash(str[i]);
		}
		sort(stu, stu + N);
		int sum = 0, Max = 0, maxn = 1, cur = 1;   //maxn记录单个的,Max记录总的,cur记录当前找到的最多的
		int i = 0;
		while (i < N) {
			int j = i + 1;
			cur = 1;
			while (stu[j] == stu[i]) {
				cur++;
				j++;
			}
			if (cur > maxn) {
				maxn = cur;
				Max = cur;
			}
			else if (cur == maxn)
				Max += maxn;
			i = j;
		}
		printf("%d\n", Max);
	}
	return 0;
}
/*
10
101 104 103 105 107
101 103 102 104 105
101 104 103 105 102
101 103 105 106 102
107 104 102 109 103
108 104 106 101 105
102 103 105 106 107
101 103 104 105 107
101 106 102 105 103
101 107 104 106 103
3
100 101 102 103 488
100 200 300 101 102
103 102 101 488 100
3
200 202 204 206 208
123 234 345 456 321
100 200 300 400 444
3
100 101 102 103 104
100 104 103 102 101
104 101 102 103 100
0

6
2
3
3
*/

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator