| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1869 人关注过本帖, 2 人收藏
标题:[讨论]]第十四期编程题目
只看楼主 加入收藏
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏(2)
 问题点数:0 回复次数:12 
[讨论]]第十四期编程题目

When Can We Meet?
Time Limit:1000MS Memory Limit:30000K
Total Submit:568 Accepted:368

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.


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 2
2 1 4
0
3 3 4 8
3 2
4 1 5 8 9
3 2 5 9
5 2 4 5 7 9
3 3
2 1 4
3 2 5 9
2 2 4
3 3
2 1 2
3 1 2 9
2 2 4
0 0


Sample Output


4
5
0
2//其实就就是在给定的几个数组中找到最小的切重复次数大于或等于要求次数的数字

Tri Tiling
Time Limit:1000MS Memory Limit:65536K
Total Submit:1919 Accepted:905

Description
In how many ways can you tile a 3xn rectangle with 2x1 dominoes?
Here is a sample tiling of a 3x12 rectangle.

Input
Input consists of several test cases followed by a line containing -1. Each test case is a line containing an integer 0 <= n <= 30.

Output
For each test case, output one integer number giving the number of possible tilings.

Sample Input

2
8
12
-1

Sample Output

3
153
2131
//第二个可能比较难一点.
希望大家积极参与..注意程序的输出格式尽量和sample output一样.以便我为大家提交.不要输出任何提示输入的信息
搜索更多相关主题的帖子: 题目 讨论 
2007-05-11 08:29
洛川
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2007-4-28
收藏
得分:0 
我英文不好,可否请楼主说得再详细点,先谢过了~

2007-05-11 09:10
限量版猪头
Rank: 2
等 级:论坛游民
威 望:1
帖 子:165
专家分:30
注 册:2006-2-5
收藏
得分:0 
一样啊,英文烂

2007-05-11 09:30
yu_hua
Rank: 2
等 级:论坛游民
帖 子:222
专家分:95
注 册:2006-8-10
收藏
得分:0 

//第二道题的编程
#include <stdio.h>
long fun(int a,int b,int c)
{
if(a*b*c==0)
return 1;
else if(a<0||b<0||c<0)
return 0;
else if(a==b&&b==c)
return fun(a-2,b-1,c-1)+fun(a-2,b-2,c-2)+fun(a-1,b-1,c-2);
else if(c-b&&b==a)
return fun(c,b,a);
else if(a>b&&b==c)
return fun(a-2,b,c);
else if(a<b&&b==c)
return fun(a,b-1,c-1)+fun(a,b-2,c-2);
else if(b>a&&a==c)
return fun(a,b-2,c);
else if(b<a&&a==c)
return fun(a-2,b,c-2);
else return 0;
}
main( )
{
int n;
while(1){
scanf("%d",&n);
if(n<0)break;
printf("%ld\n",fun(n,n,n));}
}

2007-05-11 12:05
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 

看来第一个题目很多人没有看懂:
题意:召开一个需要至少N个人的会议.虽然侯选人很多,但是很多人都是很忙的.于是会议的主办方要他们投递一个自己的时间表过来.你的任务是根据投递过来的时间表来确定最早的开会时间;
输入:
T//代表的是测试数据一共有多少组
N//代表的是至少需要的开会人数
.
.
//接下来的N行分别代表的是第i个人的时间表.时间表的格式如下
k (代表的是该议员有K个空闲时间) M1,m2,...Mk,//分别代表的是空闲日期(日期表示的是从今天起的第几天)
输出
输出符合要求的离今天最近的日期.

PS.题目的的sample input有一个小小的错误
第一行的 3 2
应该是
3
2///其实也不影响答案


2007-05-11 12:16
yu_hua
Rank: 2
等 级:论坛游民
帖 子:222
专家分:95
注 册:2006-8-10
收藏
得分:0 

//第二道题的编程(代码已优化,速度加快了)
#include <stdio.h>
long fun(int a,int b,int c)
{ if(a*b*c==0)
return 1;
else if(a<0||b<0||c<0)
return 0;
else if(a==b&&b==c)
return 2*fun(a-2,b-1,c-1)+fun(a-2,b-2,c-2);
else if(a<b&&b==c)
return fun(a,b-1,c-1)+fun(a-2,b-2,c-2);
else return 0;
}
main( )
{
int n;
while(1){
scanf("%d",&n);
if(n<0)break;
printf("%ld\n",fun(n,n,n));}
}

2007-05-11 14:26
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 
以下是引用yu_hua在2007-5-11 14:26:53的发言:

//第二道题的编程(代码已优化,速度加快了)
#include <stdio.h>
long fun(int a,int b,int c)
{ if(a*b*c==0)
return 1;
else if(a<0||b<0||c<0)
return 0;
else if(a==b&&b==c)
return 2*fun(a-2,b-1,c-1)+fun(a-2,b-2,c-2);
else if(a<b&&b==c)
return fun(a,b-1,c-1)+fun(a-2,b-2,c-2);
else return 0;
}
main( )
{
int n;
while(1){
scanf("%d",&n);
if(n<0)break;
printf("%ld\n",fun(n,n,n));}
}

除了奇数的时候应该输入0之外.其他都是对.楼上写的不错.下次题目就由你来出了


2007-05-11 16:26
crackerwang
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:833
专家分:0
注 册:2007-2-14
收藏
得分:0 

第一个怎么没有人做啊?
难道是因为太简单了或没有看懂?


2007-05-11 16:40
Javal
Rank: 1
等 级:新手上路
威 望:1
帖 子:108
专家分:0
注 册:2006-5-7
收藏
得分:0 

3 2
2 1 4
0
3 3 4 8
3 2 // 这里应该是 3 3
4 1 5 8 9
3 2 5 9
5 2 4 5 7 9
3 3
2 1 4
3 2 5 9
2 2 4
3 3
2 1 2
3 1 2 9
2 2 4
0 0

写了下第一题,可以正确得到输出

//***************************************************************
// Meet.c -- find the date convenient for the most members to
// hold a meeting.
// Author: Javal
// Date: 2007/05/11
//****************************************************************
#include<stdio.h>

#define MAX_N 51 // 最大日期
#define TEST_TIMES 10 // 测试次数
#define TRUE 1
#define FALSE 0

int main(void)
{
int freeDate[MAX_N]; // 记录每天有空的委员人数
int result[TEST_TIMES]; // 记录输出结果
int n = 0; // the size of the committee
int q = 0; // the quorum
int m = 0; // the number of convenient dates for the member
int date = 0; // 有空的日期
int i = 0;
int j = 0;
int cnt = 0; // 记录实际的测试用例数目
int flag = FALSE; // 是否找到合适的开会时间
// 数组初始化
for (i = 0; i < MAX_N; ++i)
{
freeDate[i] = 0;
}
for (i = 0; i < TEST_TIMES; ++i)
{
result[i] = 0;
}
// 取得输入并处理
while (scanf("%d%d", &n, &q) && n != 0 && q != 0)
{
j = 0;
flag = FALSE;

for (i = 0; i < MAX_N; ++i)
{
freeDate[i] = 0;
}

while (j < n)
{
scanf("%d", &m);
for (i = 0; i < m; ++i)
{
scanf("%d", &date);
++freeDate[date];
}
++j;
}
for (i = 1; i < MAX_N; ++i)
{
if (freeDate[i] >= q) // 找到最早的开会时间
{
result[cnt++] = i;
flag = TRUE;
break;
}
}
if (! flag)
{
result[cnt++] = 0; // 未找到合适的开会时间
}
}

for (i = 0; i < cnt; ++i)
{
printf("%d\n", result[i]);
}

return 0;
}


猝然临之而不惊,无故加之而不怒 /?spaced" target="_blank">Linux C资料
2007-05-11 17:30
iwfy
Rank: 1
等 级:新手上路
威 望:2
帖 子:888
专家分:0
注 册:2007-2-23
收藏
得分:0 
以下是引用yu_hua在2007-5-11 14:26:53的发言:

//第二道题的编程(代码已优化,速度加快了)

强啊


英语不好还想学编程??逆天之路,不由分说!! 数学太差还想学编程??离经叛道,义无返顾!!
2007-05-11 17:42
快速回复:[讨论]]第十四期编程题目
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022897 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved