北大ACM poj2028 When Can We Meet?
来源:互联网 发布:ibm r61 linux驱动 编辑:程序博客网 时间:2024/05/16 02:36
When Can We Meet?
Description
The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meeting. So, in order to settle the meeting date, the chairperson requested every member to send back a list of convenient dates by E-mail. Your mission is to help the chairperson, who is now dedicated to other issues of the contest, by writing a program that chooses the best date from the submitted lists. Your program should find the date convenient for the most members. If there is more than one such day, the earliest is the best.
Input
The input has multiple data sets, each starting with a line containing the number of committee members and the quorum of the meeting.
N Q
Here, N, meaning the size of the committee, and Q meaning the quorum, are positive integers. N is less than 50, and, of course, Q is less than or equal to N.
N lines follow, each describing convenient dates for a committee member in the following format.
M Date1 Date2 ... DateM
Here, M means the number of convenient dates for the member, which is an integer greater than or equal to zero. The remaining items in the line are his/her dates of convenience, which are positive integers less than 100, that is, 1 means tomorrow, 2 means the day after tomorrow, and so on. They are in ascending order without any repetition and separated by a space character. Lines have neither leading nor trailing spaces.
A line containing two zeros indicates the end of the input.
N Q
Here, N, meaning the size of the committee, and Q meaning the quorum, are positive integers. N is less than 50, and, of course, Q is less than or equal to N.
N lines follow, each describing convenient dates for a committee member in the following format.
M Date1 Date2 ... DateM
Here, M means the number of convenient dates for the member, which is an integer greater than or equal to zero. The remaining items in the line are his/her dates of convenience, which are positive integers less than 100, that is, 1 means tomorrow, 2 means the day after tomorrow, and so on. They are in ascending order without any repetition and separated by a space character. Lines have neither leading nor trailing spaces.
A line containing two zeros indicates the end of the input.
Output
For each data set, print a single line containing the date number convenient for the largest number of committee members. If there is more than one such date, print the earliest. However, if no dates are convenient for more than or equal to the quorum number of members, print 0 instead.
Sample Input
3 22 1 403 3 4 83 24 1 5 8 93 2 5 95 2 4 5 7 93 32 1 43 2 5 92 2 43 32 1 23 1 2 92 2 40 0
Sample Output
4502
/*2028题意:第一行第一个数表示有几行,第二个数表示最小的重复次数然后输入数据,第一个数表示数据的数量求重复次数大于最小重复次数的数据 */#include<stdio.h>#define N 55int n,m;int Hash[101];int i,j; int tmp1,tmp2;int main(){int max,ans; while(scanf("%d%d",&n,&m),n!=0||m!=0) { memset(Hash,0,sizeof(Hash));//初始化 for(i=1;i<=n;i++) { scanf("%d",&tmp1); for(j=1;j<=tmp1;j++) { scanf("%d",&tmp2); Hash[tmp2]++; } } max=0; ans=0; for(i=1;i<=100;i++) { if(max<Hash[i]) { max=Hash[i]; ans=i; } } if(max>=m) printf("%d\n",ans); else printf("0\n"); } return 0;}
- 北大ACM poj2028 When Can We Meet?
- poj2028 When Can We Meet?
- poj2028 When Can We Meet?
- POJ2028 When Can We Meet?
- POJ2028 When Can We Meet? 水题
- POJ2028——When Can We Meet?
- ZOJ1715 POJ2028 When Can We Meet? 简单的数组题
- 2028 When Can We Meet?
- (简单)When Can We meet?
- zoj1715---------------------When Can We Meet?
- 1715 When Can We Meet?
- zoj 1751 When Can We Meet?
- ZOJ 1715 When Can We Meet?
- POJ 2028 When can we meet?
- zoj 1715 When Can We Meet?
- ZOJ 1715 When Can We Meet?
- poj 2028 When Can We Meet?
- POJ 2028 When Can We Meet? 枚举
- 分享8年开发经验,浅谈个人发展经历,明确自己发展方向
- 代码量评估
- 在JTable中添加可视化组件
- 飞秋实现的原理
- 行为导向的人有哪些表现
- 北大ACM poj2028 When Can We Meet?
- comScore:价格是消费者选购Android平板的首要因素
- 程序员技术练级攻略
- DPM 2012保护Hyper-V主机
- Linux 系统监控负载top命令详解
- 关于delphi7的几个问题
- POJ 1860 Currency Exchange bellman_ford
- ATL_NO_VTABLE详解
- UIApplicationDelegate 包含下面几个函数监控应用程序状态的改变: