2013
12-23

# Conformity

Frosh commencing their studies at Waterloo have diverse interests, as evidenced by their desire to take various combinations of courses from among those available.
University administrators are uncomfortable with this situation, and therefore wish to offer a conformity prize to frosh who choose one of the most popular combinations of courses. How many frosh will win the prize?

The input consists of several test cases followed by a line containing 0. Each test case begins with an integer 1 ≤ n ≤ 10000, the number of frosh. For each frosh, a line follows containing the course numbers of five distinct courses selected by the frosh. Each course number is an integer between 100 and 499.

The popularity of a combination is the number of frosh selecting exactly the same combination of courses. A combination of courses is considered most popular if no other combination has higher popularity. For each line of input, you should output a single line giving the total number of students taking some combination of courses that is most popular.

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
0

2
3

#include<stdio.h>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
using namespace std;
int s[10001][6];
int main()
{
int n,i,j,sum,max,num;
map<string,int>::iterator it;
map<string,int>ans;
while(scanf("%d",&n),n)
{
ans.clear();
for(i=1;i<=n;i++)
for(j=0;j<5;j++)
scanf("%d",&s[i][j]);
for(i=1;i<=n;i++)
sort(s[i],s[i]+5);
for(i=1;i<=n;i++)
{
string str;
for(j=0;j<5;j++)
{
char a[5];
itoa(s[i][j],a,10);
str+=a;
}
ans[str]++;
}
max=num=0;
for(it=ans.begin();it!=ans.end();it++)
if(it->second>max)max=it->second;
for(it=ans.begin();it!=ans.end();it++)
if(it->second==max)num++;
printf("%d\n",num*max);
}
return 0;
}

1. 第一句可以忽略不计了吧。从第二句开始分析，说明这个花色下的所有牌都会在其它里面出现，那么还剩下♠️和♦️。第三句，可以排除2和7，因为在两种花色里有。现在是第四句，因为♠️还剩下多个，只有是♦️B才能知道答案。

2. 其实国内大部分公司对算法都不够重视。特别是中小型公司老板根本都不懂技术，也不懂什么是算法，从而也不要求程序员懂什么算法，做程序从来不考虑性能问题，只要页面能显示出来就是好程序，这是国内的现状，很无奈。

3. 您没有考虑 树的根节点是负数的情况， 若树的根节点是个很大的负数，那么就要考虑过不过另外一边子树了