代码改变世界

河南省大学生程序设计竞赛863软件园杯第一界试题

2009-05-13 04:05  Logic0  阅读(481)  评论(0编辑  收藏  举报
我顶 字号:

第一题

灾区已经非常困难,灾民需要帐篷、衣物、食品和血浆。可通往灾区的道路到处都是塌方,70%以上的路面损坏,桥梁全部被毁。中国空军立即启动应急预案,展开史上最大强度非作战空运行动,准备向灾区空投急需物资。由于余震不断,天气恶劣,怎样知道空投的物资是否落在某灾区的区域内?

经过空中观测,多数灾区为一圆形,空投的物资落在P(Xj,Yj)点。你能否给出一个正确判断?

标准输入

  第   1   行: N  M             (N灾区数,  M 空投的物资数)

接下有N行:Xi0  Yi0   Ri     Xi0 Yi0)为圆心坐标, Ri为圆半径 i=1, 2, …., N

接下有M行:Xj  Yj          Xj Yj为空投物资的坐标 j=1, 2, …., M

标准输出

输出有M行,每一行输出 YES   NO  (若物资落在某个圆上或圆内,输出YES否则输出NO 

约束条件

(1)         1 N 3     2 M 10    

(2)        Ri 是一个正整数    Ri <=50      i=1, 2, …., N

(3)         所有的圆心坐标和物资的坐标均为整数  范围均在[-100100]

(4)        时间限制: 1000MS

 

标准输入

标准输出

2  3

0 0 20

-70 30 50

10 10

-30 60

30 30

YES

YES

NO


第二题

 据不完全统计,受地震影响,四川大部分灾区通信陷入瘫痪,数千个基站因断电、传输中断等原因退出服务,目前总公司已紧急部署对受灾地区进行通信抢修。按照应急通信保障预案,必须尽快、付出代价最小,效率更高来全力恢复通信。

 由于四川大部分灾区都处于山区,有很多基站之间不能直接建立通信。现已知建立各基站之间直接通信的代价,问如何建立总代价最小的通信网,使得任意两个基站之间都能通信?

标准输入

  第  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

1 2 160

1 3  30

1 4 20

2 3 200

3 4 50

3 5 80

5 4  70

280

 

     第三题

     密码破译

 某组织欲破获一个外星人的密码,密码由一定长度的字串组成。此组织拥有一些破译此密码的长度不同的钥匙,若两个钥匙的长度之和恰好为此密码的长度,则此密码被成功破译。现在就请你编程找出能破译此密码的两个钥匙。

 

标准输入

第 一  行: N                  N为钥匙的个数(1<=N<=1000

第 二  行: L                  L为密码的长度

以下有N行: Ai                每一行是一把钥匙的长度  i=12……,N

标准输出

    若无法找到破译此密码的钥匙,则输出0

    若找到两把破译的钥匙,则输出文件有两行,分别为两把钥匙的编号,按从小到大输出。若有多种破译方案,则只输出包含起始编号最小的一组即可。

约束条件

11<= NLAi <=1000    (  i=1, 2, ….., N )

2)时间限制: 1000MS

 

 

标准输入

标准输出

10

80

27

9

4

73

23

68

12

64

92

16

6

7

 

第四题

在灾区,多数人已经受伤,缺水,少食物,精神处在崩溃的边缘。很多人的生存条件仅能维持几天。灾民需要帐篷、衣物、食品和医疗器材、药品等物资。14日上午,中央军委委员、空军司令员许其亮组织召开空军首长办公会,将空军下一步救灾重点确定为抢救伤员、空投、空运。空军各部队都派出多架运输机,准备向灾区空运急需物品。

现在已知四种打包过的急需物品重量分别为C1, C2, C3,C4 ,数量分别为M1M2M3M4包。一架运输机的载重量为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范围内

约束条件

10< Cj <= 1000    0 <= Mij <= 500    i =1,2,….. , N    j =1,2,3,4

2N<=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

 


   第五题

 从512日下午地震发生至今已经超过48小时,根据地震救灾的常识推算,未来24小时将是救灾最后的黄金时间。时间在无情的流逝,数以万计的灾民依旧命悬喘息之间。现在,数万军民正日夜奋战在抢救灾民第一线。从人员的组织协调到救灾物资的后援运输,每一个环节都直接关系到救灾的效果好坏。

 由于通往各灾区的道路完全中断,大批救援物资只好空投到各个灾区。某军区准备了一批物, 恰好能均分到处于环形的N个灾区中。遗憾的是,由于余震不断,天气恶劣等原因,落到各灾区的数量不相同。

 正如***总理所一再强调的抢救人的生命,是这次救灾工作的重中之重 。为了保证救灾的效率不会平白消耗, 当地的民间救助组织可以选择将落到自己所在区的物资传送到左边或者右边相邻的灾区。为了公平起见,我们希望通过相邻灾区的相互传送,最终使所有的灾区获得相同数量的物资。假设一个物资从一个灾区传送到另一个灾区付出的代价是1, 问怎样进行传送,使得所付出的总代价最小。

【标准输入】

  第 一 行:  N               表示处于环形的灾区数

接下来n行: 每行一个整数Ai,   表示第i灾区得到的物质数

【标准输出

输出只有一个数, 表示传送物资付出的最小总代价

【约束条件】

1 N<=1000000

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 (ceiling) 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 how many sticks he had originally and how long they were originally. Please help him 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.    y y y… y  is the sorted, ascending sequence.

Sorted sequence cannot be determined.

Inconsistency found.

 

Sample Input              Sample  Output  

4 6                     Sorted sequence determined: A B C D.

A<B                        Inconsistency found.

A<C                        Sorted sequence cannot be determined.

B<C

C<D

B<D

A<B

3 2

A<B

B<A

26 2

A<Z

D<S

0 0