为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

第一届ACM试题

2017-09-29 13页 doc 31KB 30阅读

用户头像

is_358746

暂无简介

举报
第一届ACM试题第一届ACM试题 考试时间: 5小时,9:00 ~ 14:00, 分数分布: 共8题~满分800分。 文件命名: 程序文件名为:T题号。例如:若用C语言~第二题应提交:T2.C 【试题一】 灾区已经非常困难,灾民需要帐篷、衣物、食品和血浆。可通往灾区的道路到处都是塌方,70%以上的路面损坏,桥梁全部被毁。中国空军立即启动应急预案,展开史上最大强度非作战空运行动,准备向灾区空投急需物资。由于余震不断,天气恶劣,怎样知道空投的物资是否落在某灾区的区域内, 经过空中观测,多数灾区为一圆形,空投的物资落在P(Xj,Yj)点。...
第一届ACM试题
第一届ACM试 考试时间: 5小时,9:00 ~ 14:00, 分数分布: 共8题~满分800分。 文件命名: 程序文件名为:T题号。例如:若用C语言~第二题应提交:T2.C 【试题一】 灾区已经非常困难,灾民需要帐篷、衣物、食品和血浆。可通往灾区的道路到处都是塌方,70%以上的路面损坏,桥梁全部被毁。中国空军立即启动应急预案,展开史上最大强度非作战空运行动,准备向灾区空投急需物资。由于余震不断,天气恶劣,怎样知道空投的物资是否落在某灾区的区域内, 经过空中观测,多数灾区为一圆形,空投的物资落在P(Xj,Yj)点。你能否给出一个正确判断, 【输入】 第1行: N M (N为灾区数, M 为空投的物资数) 接下有N行:Xi0 Yi0 Ri (Xi0 ,Yi0)为圆心坐标, Ri为圆半径 i=1, 2, …., N 接下有M行:Xj Yij (Xj ,Yj)为空投物资的坐标 j=1, 2, …., M ) 【标准输出】 输出有M行,每一行输出 YES (若物资落在某个圆上或圆内,输出YES 或 NO 否则输出NO ) 【约束条件】 (1) 1 ? N ? 3 2 ? M ? 10 (2) Ri 是一个正整数 Ri <=50 i=1, 2, …., N (3) 所有的圆心坐标和物资的坐标均为整数 范围均在[-100,100]内 (4) 时间限制: 1000MS 【 样 例 】 标准输入 标准输出 2 3 YES 0 0 20 YES -70 30 50 NO 10 10 -30 60 30 30 【试题二】 据不完全统计,受地震影响,四川大部分灾区通信陷入瘫痪,数千个基站因断电、传输中断等原因退出服务,目前总公司已紧急部署对受灾地区进行通信抢修。按照应急通信保障预案,必须尽快、付出代价最小,效率更高来全力恢复通信。 由于四川大部分灾区都处于山区,有很多基站之间不能直接建立通信。现已知建立各基站之间直接通信的代价,问如何建立总代价最小的通信网,使得任意两个基站之间都能通信, 【标准输入】 第1行: N M (N为基站数 M为能直接建立通信关系数 ) 接下有M行: I J P (每行有三个数。I J 为基站的编号 P为基站I与基站之间直接通信的代价) 【标准输出】 T (建立通信网的最小代价数) 【约束条件】 (1) 2 ? N ?100 10 ? M ?1000 (2) 0 < P ? 1000 P为正整数 (3) 时间限制: 1000MS 【 样 例 】 标准输入 标准输出 5 7 280 1 2 160 1 3 30 1 4 20 2 3 200 3 4 50 3 5 80 5 4 70 【试题三】 密码破译 某组织欲破获一个外星人的密码,密码由一定长度的字串组成。此组织拥有一些破译 此密码的长度不同的钥匙,若两个钥匙的长度之和恰好为此密码的长度,则此密码被成功破 译。现在就请你编程找出能破译此密码的两个钥匙。 【标准输入】 第一行: N N为钥匙的个数(1<=N<=1000) 第二行: L L为密码的长度 以下有N行: Ai 每一行是一把钥匙的长度 i=1,2,……,N 【标准输出】 若无法找到破译此密码的钥匙,则输出0 若找到两把破译的钥匙,则输出文件有两行,分别为两把钥匙的编号,按从小到大 输出。若有多种破译,则只输出包含起始编号最小的一组即可。 [【约束条件】 (1)1<= N,L,Ai <=1000 ( i=1, 2, ….., N ) (2)时间限制: 1000MS 【 样 例 】 标准输入 标准输出 10 6 80 7 27 9 4 73 23 68 12 64 92 16 【试题四】 在灾区,多数人已经受伤,缺水,少食物,精神处在崩溃的边缘。很多人的生存条件仅能维持几天。灾民需要帐篷、衣物、食品和医疗器材、药品等物资。14日上午,中央军委委员、空军司令员许其亮组织召开空军首长办公会,将空军下一步救灾重点确定为抢救伤员、空投、空运。空军各部队都派出多架运输机,准备向灾区空运急需物品。 现在已知四种打包过的急需物品重量分别为C1, C2, C3,C4 ,数量分别为M1,M2,M3,M4包。一架运输机的载重量为W, 现在各部队关心将一架运输机装满共有多少种运载方案,以便调度进行空运。 比如C={ 100, 200, 500, 1000}, M={ 3, 2, 3, 1 }, W=1000, 一共有4种运载方案: 1000=100+100+100+200+500 1000=100+200+200+500 1000=500+500 1000=1000 【标准输入】 第一行: C1 C2 C3 C4 N 其中 N为空运的部队数 接下来n行: Mi1 Mi2 Mi3 Mi4 Wi 示各运载部队需空运的4种物品数量Mi 和各自运输机的载重量Wi i=1,2,….. , N 【标准输出】 输出有N行,表示各部队运载物品的方案总数,保证答案在10000范围内 【约束条件】 (1)0< Cj <= 1000 0 <= Mij <= 500 i =1,2,….. , N j =1,2,3,4 (2)N<=1000 0 < Wi <= 100000 i =1,2,….. , N (3)时间限制: 1000MS 【 样 例 】 标准输入 标准输出 1 2 5 10 2 4 27 3 2 3 1 10 1000 2 2 2 900 【试题五】 从5月12日下午地震发生至今已经超过48小时,根据地震救灾的常识推算,未来24小时将是救灾最后的黄金时间。时间在无情的流逝,数以万计的灾民依旧命悬喘息之间。现在,数万军民正日夜奋战在抢救灾民第一线。从人员的组织协调到救灾物资的后援运输,每一个环节都直接关系到救灾的效果好坏。 由于通往各灾区的道路完全中断,大批救援物资只好空投到各个灾区。某军区准备了一批物资, 恰好能均分到处于环形的N个灾区中。遗憾的是,由于余震不断,天气恶劣等原因,落到各灾区的数量不相同。 正如温家宝总理所一再强调的“抢救人的生命,是这次救灾工作的重中之重” 。为了保证救灾的效率不会平白消耗, 当地的民间救助组织可以选择将落到自己所在区的物资传送到左边或者右边相邻的灾区。为了公平起见,我们希望通过相邻灾区的相互传送,最终使所有的灾区获得相同数量的物资。假设一个物资从一个灾区传送到另一个灾区付出的代价是1, 问怎样进行传送,使得所付出的总代价最小。 【标准输入】 第一行: N 表示处于环形的灾区数 接下来n行: 每行一个整数Ai, 表示第i个灾区得到的物质数量。 【标准输出】 输出只有一个数, 表示传送物资付出的最小总代价 【约束条件】 =1000000 (1) N< (2) Ai>=0, 保证Ai在长整型范围内, Ai的总和在int64/long long范围内. (3)时间限制: 1000MS 【 样 例 】 标准输入 标准输出 4 4 1 2 5 4 【试题六】 Time Limit: 1000MS The disaster is order, and the time is life. Relief troops must reach the disaster scene as fast as possible. At 10:00 on the 13th, in the disaster relief headquarters of the Chengdu Military Area, Li Shiming, commander of the Chengdu Military Area Command, shouted loudly :"No matter generals or soldiers, whoever reach the quake-hit areas in the earliest time will be awarded the glory." We may assume that all the soldiers except "Yongshi" run from Chengdu to Wenchuan at a fixed speed. Yongshi is a soldier with a different running habit – he always tries to follow another soldier to avoid running alone. When Yongshi gets to Chengdu , he will look for someone who is setting off to Wenchuan. If he finds someone, he will follow that soldier, or if not, he will wait for someone to follow. On the way from Chengdu to Wencuan, at any time if a faster soldier surpassed Yongshi , he will leave the soldier he is following and speed up to follow the faster one. We assume the distance from Chengdu to Wenchuan is 95 kilometers and the time that Yongshi gets to Chengdu is zero. Given the set off time and speed of the other soldier, your task is to give the time when Yongshi arrives at Wenchuan. 【Input】 There are several test cases (<=10 test cases). The first line of each case is N (1 <= N <= 1000) representing the number of soldier (excluding Yongshi ). N = 0 ends the input. The following N lines are information of N different soldiers, in such format: Vi Ti Vi is a positive integer <= 30, indicating the speed of the i-th soldier (kph, kilometers per hour). Ti is the set off time of the i-th soldier, which is an integer and counted in minutes. In any case it is assured that there always exists a nonnegative Ti. -1000<= Ti <=1000 【Output 】 Output one line for each case: the arrival time of Yongshi. Round up the value when dealing with a fraction. Sample Input Sample Output 4 214 10 0 271 12 -15 15 19 30 24 2 21 0 22 34 0 【试题七】 George took sticks of the same length and cut them randomly until all parts became at most 20 units long. Now he wants to return sticks to the original state, but he forgot ow many sticks he had originally and how long they were originally. Please help him h and design a program which computes the smallest possible original length of those sticks. All lengths expressed in units are integers greater than zero. 【Input】 Input consists of multiple problem instances. Each instance contains blocks of 2 lines. The first line contains the number of sticks parts after cutting, there are at most 64 sticks. The second line contains the lengths of those parts separated by the space. The last line of the file contains zero. 【Output】 The output should contains the smallest possible length of original sticks, one per line. Sample Input 9 5 2 1 5 2 1 5 2 1 4 1 2 3 4 0 Sample Output 6 5 Time Limit: 1000MS 【试题八】 An ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For example, the sorted sequence A, B, C, D implies that A < B, B < C and C < D. in this problem, we will give you a set of relations of the form A < B and ask you to determine whether a sorted order has been specified or not. 【Input】 Input consists of multiple problem instances. Each instance starts with a line containing two positive integers n and m. the first value indicated the number of objects to sort, where 2 <= n <= 26. The objects to be sorted will be the first n characters of the uppercase alphabet. The second value m indicates the number of relations of the form A < B which will be given in this problem instance. 1 <= m <= 100. Next will be m lines, each containing one such relation consisting of three characters: an uppercase letter, the character "<" and a second uppercase letter. No letter will be outside the range of the first n letters of the alphabet. Values of n = m = 0 indicate end of input. 【Output】 For each problem instance, output consists of one line. This line should be one of the following three: Sorted sequence determined: y y y… y. Sorted sequence cannot be determined. Inconsistency found. y y y… y is the sorted, ascending sequence. Sample Input Sample Output 4 6 Sorted sequence determined: A B C D. A设计
了一个可以前进或后退的机器人,该机器人在每个位置i会得到一个移动步数的 指令Ki(i=1,2……N) 聪明的机器人判断是应该前进 Ki步还是倒退Ki步 例如给定指令序列(3 3 1 2 5),表示机器人在第一个位置时可以前进3个位置到第4个位置,此时不可以倒退,因为倒退就越界了(1-3=-2)在第2个位置可以前进3个位置,此时还 不可以倒退,在第3个位置上可以前进1个位置到第4个位置,或者后退1个位置到第2个位置…… 问:对于给定的序列指(x1,x2,x3……)和A B两个位置,机器人从A到B,至少要判断几次, 要求: 输入: 第一行:M 表示下面要测试的数据组数。 接下来每组两行数据 头一行N A B(n表示指令数,1
/
本文档为【第一届ACM试题】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索