第三届ACM程序设计大赛试题new
ACM
计算机工程学院
第三届ACM程序设计大赛试题
Problem A Bridge
Description
n people wish to cross a bridge at night. A group of at most two people may cross at any time, and each group must have a flashlight. Only one flashlight is available among the n people, so some sort of shuttle arrangement must be arranged in order to return the flashlight so that more people may cross. Each person has a different crossing speed; the speed of a group is determined by the speed of the slower member. Your job is to determine a strategy that gets all n people across the bridge in the minimum time.
Input
The first line of input contains n, followed by n lines giving the crossing times for each of the people. There are not more than 1000 people and nobody takes more than 100 seconds to cross the bridge.
Output
The first line of output must contain the total number of seconds required for all n people to cross the bridge. The following lines give a strategy for achieving this time. Each line contains either one or two integers, indicating which person or people form the next group to cross. (Each person is indicated by the crossing time specified in the input. Although many people may have the same crossing time the ambiguity is of no consequence.) Note that the crossings alternate directions, as it is necessary to return the flashlight so that more may cross. If more than one strategy yields the minimal time, any one will do.
Sample Input(Input file: pa.txt)
4 1 2 5 10
Sample Output
17 1 2 1 5 10 2 1 2
ACM
Problem B Lotto
Description
In the German Lotto you have to select 6 numbers from the set {1,2,...,49}. A popular strategy to play Lotto - although it doesn't increase your chance of winning - is to select a subset S containing k (k > 6) of these 49 numbers, and then play several games with choosing numbers only from S. For example, for k=8 and S = {1,2,3,5,8,13,21,34} there are 28 possible games: [1,2,3,5,8,13], [1,2,3,5,8,21], [1,2,3,5,8,34], [1,2,3,5,13,21], ... [3,5,8,13,21,34].
Your job is to write a program that reads in the number k and the set S and then prints all possible games choosing numbers only from S.
Input
The input will contain one or more test cases. Each test case consists of one line containing several integers separated from each other by spaces. The first integer on the line will be the number k (6 < k < 13). Then k integers, specifying the set S, will follow in ascending order. Input will be terminated by a value of zero (0) for k.
Output
For each test case, print all possible games, each game on one line. The numbers of each game have to be sorted in ascending order and separated from each other by exactly one space. The games themselves have to be sorted lexicographically, that means sorted by the lowest number first, then by the second lowest and so on, as demonstrated in the sample output below. The test cases have to be separated from each other by exactly one blank line. Do not put a blank line after the last test case.
Sample Input (Input file: pb.txt)
7 1 2 3 4 5 6 7
8 1 2 3 5 8 13 21 34 0
Sample Output
1 2 3 4 5 6 1 2 3 4 5 7 1 2 3 4 6 7 1 2 3 5 6 7 1 2 4 5 6 7 1 3 4 5 6 7 2 3 4 5 6 7
1 2 3 5 8 13 1 2 3 5 8 21 1 2 3 5 8 34 1 2 3 5 13 21 1 2 3 5 13 34 1 2 3 5 21 34
ACM
1 2 3 8 13 21 1 2 3 8 13 34 1 2 3 8 21 34 1 2 3 13 21 34 1 2 5 8 13 21 1 2 5 8 13 34 1 2 5 8 21 34 1 2 5 13 21 34 1 2 8 13 21 34 1 3 5 8 13 21 1 3 5 8 13 34 1 3 5 8 21 34 1 3 5 13 21 34 1 3 8 13 21 34 1 5 8 13 21 34 2 3 5 8 13 21 2 3 5 8 13 34 2 3 5 8 21 34 2 3 5 13 21 34 2 3 8 13 21 34 2 5 8 13 21 34 3 5 8 13 21 34
Problem C Encrypt
Chip and Dale have devised an encryption method to hide their (written) text messages. They first agree secretly on two numbers that will be used as the number of rows (R) and columns (C) in a matrix. The sender encodes an intermediate format using the following rules: 1. The text is formed with uppercase letters [A-Z] and <space>.
2. Each text character will be represented by decimal values as follows: <space> = 0, A = 1, B = 2, C = 3, ..., Y = 25, Z = 26
The sender enters the 5 digit binary representation of the characters' values in a spiral pattern along the matrix as shown below. The matrix is padded out with zeroes (0) to fill the matrix completely. For example, if the text to encode is: "ACM" and R=4 and C=4, the matrix would be filled in as follows:
A = 00001, C = 00011, M = 01101 (one extra 0)
The bits in the matrix are then concatenated together in row major order and sent to the receiver. The example above would be encoded as: 0000110100101100
Input
The first line of input contains a single integer N, (1 ≤ N ≤ 1000) which is the number of datasets that follow.
Each dataset consists of a single line of input containing R (1 ≤ R ≤ 20), a space, C (1 ≤ C ≤ 20), a
ACM
space, and a string of binary digits that represents the contents of the matrix (R * C binary digits). The binary digits are in row major order.
Output
For each dataset, you should generate one line of output with the following values: The dataset number as a decimal integer (start counting at one), a space, and the decoded text message. You should throw away any trailing spaces and/or partial characters found while decoding.
Sample Input(Input file: pc.txt)
2
4 4 ACM 5 2 HI
Sample Output
1 0000110100101100 2 0110000010
Problem D Connection
There are N cities in the country and M bidirectional roads between the cities. The government wants to build some new roads such that for any pair of cities there is at least one path between them. Now you have to find out the minimal amount of roads that have to build.
相关推荐:
- [高等教育]一年级家长课程教案
- [高等教育]封丘县人民医院深入推进纠正医药购销领
- [高等教育]2017年6月大学英语四级真题试卷及答案(
- [高等教育]2017年北京第二外国语学院文学院824中
- [高等教育]7 高中历史第7单元1861年俄国农奴制改
- [高等教育]【K12学习】4、实际测量-苏教版六年级
- [高等教育]药具培训试卷题库及部分参考答案
- [高等教育]本土电子元器件目录分销商如何赢得生意
- [高等教育]七年级岭南版美术教案
- [高等教育]书作文之书法活动通讯稿
- [高等教育]Endnote X 软件使用入门和用法总结(LS)
- [高等教育]嵌入式系统的现状及发展状况
- [高等教育]2012抗菌药物专项整治活动方案解读
- [高等教育]人教版新课本一年级数学下册期末试卷
- [高等教育]爱课程民法学观后感
- [高等教育]930机组使用说明书1
- [高等教育]煤气设备设施点检标准
- [高等教育]常见室内观叶植物图解
- [高等教育]312党员群众路线心得体会
- [高等教育]小学信息(苗版)第一册全册教案
- 在市---局2010党建大会上的讲话
- 《科哲》提纲及补充阅读材料(2010.7)
- 苏州高博软件技术职业学院论文开题报告
- 兼职导游管理的困境及对策探讨
- 基于通用设计理念的现代厨房产品语义研
- 康乐一中2010年至2011年度鼓号队、花束
- 第10章_数据收集整理与描述_期末复习课
- 2008年黑龙江林甸商贸购物中心营销策划
- 水硬度的测定实验报告
- 五分钟教你拍摄夜景光绘照
- 2014年临床妇产科三基三严试题及答案
- 0第二课 纾解压力第一站了解压力
- 解析建筑工程电气设备安装施工技术要点
- 地方性应用型本科高校“双师型”师资队
- 高考语文专题复习课件:小说阅读指导
- 装饰工程投标书2
- 大学生就业难问题探讨及对策
- English and Its History
- 青岛市城市房屋修缮工程质量监督管理办
- 初中英语形容词和副词的用法和练习题




