收藏 分享(赏)

ACM第3周周赛试题.doc

上传人:tkhy51908 文档编号:7222312 上传时间:2019-05-10 格式:DOC 页数:13 大小:72KB
下载 相关 举报
ACM第3周周赛试题.doc_第1页
第1页 / 共13页
ACM第3周周赛试题.doc_第2页
第2页 / 共13页
ACM第3周周赛试题.doc_第3页
第3页 / 共13页
ACM第3周周赛试题.doc_第4页
第4页 / 共13页
ACM第3周周赛试题.doc_第5页
第5页 / 共13页
点击查看更多>>
资源描述

1、A:Max Sum of Max-K-sub-sequence(3415)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)1Total Submission(s): 525 Accepted Submission(s): 51Problem DescriptionGiven a circle sequence A1,A2,A3An. Circle sequence means the left neighbour of A1 is An , and the right neighbo

2、ur of An is A1.Now your job is to calculate the max sum of a Max-K-sub-sequence. Max-K-sub-sequence means a continuous non-empty sub-sequence which length not exceed K.InputThe first line of the input contains an integer T(1= 0 & a + b + c = 9) Meaning of a, b, and c are described in the problem sta

3、tement. The last case contains exactly three 0s for all of a, b, c and indicates the end of input stream. This line should not be processed.OutputYour program should print a single integer for each input in a single line. The integer will state that how many solution there are for the given size of

4、a, b and c.Sample Input2 3 41 1 10 0 0Sample Output74Note:The valid solutions for the second sample input-output are as following:2*3 =62*4 =83*2 =64*2 =8F:Bus FairTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 978 Accepted Submission(s): 291Prob

5、lem DescriptionYou are now in Foolish Land. Once moving in Foolish Land you found that there is a strange Bus fair system. The fair of moving one kilometer by bus in that country is one coin. If you want to go to X km and your friend wants to go to Y km then you can buy a ticket of X+Y coins (you ar

6、e also allowed to buy two or more tickets for you two).Now as a programmer, you want to show your creativity in buying tickets! Suppose, your friend wants to go 1 km and you want to go 2 km. Then its enough for you to buy a 2coin ticket! Because both of you are valid passengers before crossing the f

7、irst km. and when your bus cross the first km your friend gets down from the bus. So you have the ticket of 2km! And you can safely reach to your destination, 2km using that ticket.Now, you have a large group of friends and they want to reach to different distance. You think that you are smart enoug

8、h that you can buy tickets that should manage all to reach their destination spending the minimum amount of coins. Then tell us how much we should at least pay to reach our destination.InputThere are multiple test cases. Each case start with a integer n, the total number of people in that group. 0=n

9、=1000. Then comes n integers, each of them stands for a distance one of the men of the group wants to go to. You can assume that the distance a man wants to go is always less than 10000.OutputYour program should print a single integer for a single case, the minimum amount of coins the group should s

10、pend to reach to the destination of all the members of that group.Sample Input212223Sample Output24G:Max Sum IITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2014 Accepted Submission(s): 260Problem DescriptionGiven a sequence a1,a2,a3an, you can

11、cut the sequence into one or more consecutive sub-sequences as you want, for example, you can cut them into (a1.aj), (ak.al), (am.an),1jklmn. Your job is to make the maximum sum using the least number of consecutive sub-sequences. For example, given (6,-1,0, -2, 3), the max sum in this sequence is 9

12、, the number of sub-sequences is 2 not 3, they are(6), (3).InputThe first line of the input contains an integer T(1=T=20) which means the number of test cases. Then T lines follow, each line starts with a number N(1=N=1000000), then N integers followed(all the integers are between -1000 and 1000).Ou

13、tputFor each test case, you should output two lines. The first line is “Case #:“, # means the number of the test case. The second line contains two integers, the number of consecutive sub-sequences and the max sum. Output a blank line between two cases.Sample Input22 6 -55 6 -1 0 -2 3Sample OutputCa

14、se 1:1 6Case 2:2 9H:TriangleTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 640 Accepted Submission(s): 241Problem DescriptionK likes to play with the balls.That day he piled a triangle (n layers, layer 1 start,the first layer has 1 ball,the secod

15、e layer has 2 balls,the nth layer has n balls), but he felt uncomfortable after completion, and want to pile a right triangle, because he felt that the number 4 is a lucky one (because of “si ji fa cai”). So he decided to use 4 times of the balls he just used as a right-edge side of the right triang

16、le(the three edges have no common factor).He only to pile the three edges,that is the middle is empty.But there will not have so many balls,so he wants to know the minimum of balls he must use.Now ,he turn to you for help.InputThe layer of the triangle as the promble describes n,1 = n 216OutputThe m

17、inimum of balls he must use and the length of the hypotenuse. One case one line Sample Input123Sample Output9 527 1353 25The second case:Let the right_edge promble describles is b ,The layer is 2,so b is 4 * (1 + 2) = 12.wo can know the edges of right triangle is 5 , 12 ,13.So the minimum of balls h

18、e must use is (5 + 12 + 13 3) = 27Subway upgradeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 69 Accepted Submission(s): 15Problem DescriptionAs we all know, one of the most important inventions for modern-day public transportation is the subway

19、, which brings much convenience to our daily-life and saves us from the congested traffic.However, to hold the next ACM regional contest, you, as the mayor of city X, decided to upgrade the subway system of that city. There are some stations and roads in the city now, any road has a cost. To save mo

20、ney, you decided not to construct every road, but to make sure that there exist a path between every two stations.Sorry, the mission isnt completed. You know, there are n stations in the city,some contestants visit other stations regularly to admire some so-called big cows. Being naturally averse to

21、 spending hours each day on commuting, you should help them to find a place to live for which the total travel time is minimal.Every road has an ID, from 1 to m. If there are multiple approaches leading to the same minimal cost, the mayor prefers the one of which road IDs selected holds the smallest

22、 lexicographic order. For instance, rebuilding ID ( 1 3 5) and ID (2 4 5) will both ensure the minimum cost,the mayor will choose the former one.InputFirst,a number t,indicating the number of the testcases.For every testcase, there is a number n and m,n(1=n=50000) indicating the number of cities,whe

23、reas m (0=m=500000) indicating the number of roads.then m lines follow each lines contains three integers a,b,c.(1=a,b=n&a!=b,1=c=10000)which means there is a road from a to b whose cost is c.OutputFirst the minimum cost.If doesnt exist,only output “Poor mayor.“(without quotes)Then output the answer

24、 and all the candidate stations.Sample Input33 31 2 102 3 203 1 153 11 2 152 11 2 15Sample Output25150Poor mayor.151 230Hint:In the first sample we use road 1 and 3 ,the minimus cost is 10+15=25and we get a new graph 3-1-2,city 1 is the best answer ,2*10+2*15=50Whereas the third, we cant get city 1,2,3 connected.In the last, we choose the road 1,the minimus cost is 15and we get a new graph 1-2,both city 1 and city 2 are the best answer ,2*15=30

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报