请编写程序,帮助Drkong计算一下,卡多最多能带出多少个藏宝地点的宝物。
【标准输入】
第一行: N M K W
接下来K行, 每行一个整数,表示有藏有宝物的地点标号。
在接下来M行,每行三个整数X,Y,Z,表示地点X与地点Y之间有一条危险
度为Z的通路。
【标准输出】
输出一个整数, 表示卡多最多能带出的宝物的堆数。
【约束条件】
1<=N<=8000 1<=K<=N 1<=M<=15000 1<=W,Z<=10000 数据保证所有的地点之间都是有道路可以到达的。
提示:机器人卡多经过一个宝藏地点是可以不拿走宝物,而且同一宝藏的点可以经过多次。
【样 例】 标准输入 6 7 5 1 1 2 3 4 5 1 2 3 3 6 2 6 2 10 2 4 1 5 1 1 4 5 1 1 6 1 标准输出 4 [ T6]
SUBSTRING
You are given a string input. You are to find the longestsubstring of input such that the reversal of the substring is also a substring of input . In case of a tie , return the string that occurs earliest in input.
Note well: The substring and its reversal may overlap partially or completely. The entire original string is itself a valid substring. The best we can do is find a one character substring , so we implement the tie-breaker rule of taking the earliest one first.
[Standard ouput]
The first line of input gives a single integer, 1<=N<=10, the number of test case. Then follow ,for each test case , a line containing between 1 and 50 characters, inclusive .Each character of input will be an uppercase letter(?A‘-?Z‘).
[Standard output]
Output for each test case the longest substring of input such that the reversal of the substring is also a substring of input.
[Sample input]
3
ABCABA XYZ XCVCX
[Sample Output]
ABA X
XCVCX
[ T7 ]
BOBSLEDDING
Dr.kong has entered a bobsled competition because he hefty weight wil give his an advantage over the L meter course(2<=L<=1000).
Dr.kong will push off the starting line at 1 meter per second ,but his speed can change while he rides along the course. Near the middle of every meter per second or by braking to stay at the same speed or decrease his speed by one meter per second .
Naturally, Dr.kong must negotiate N(1<=N<=500) turns on the way down the hill. Turn i is located T_i meters from the course start (1<=T_i<=L-1),and he must be enter the corner meter at a peed of at most S_i meters per second (1<=S_i<=1000). Dr.kong can cross the finish line at any speed he likes.
Help Dr.kong learn the fastest speed he can attain without exceeding the speed limits on the turns . Consider this course with the meter markers as integers and the turn speed limits in brackets(e.g,‘[3]‘):
0 1 2 3 4 5 6 7[3] 8 9 10 11[1] 12 13[8] 14
(start)|-------------------------------------------------------------------------------|(finish)
Below is a chart of Dr.kong‘s speeds at the beginning of each meter length of the course: Max: [ 3 ] [ 1 ] [ 8 ]
Mtrs: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Spd: 1 2 3 4 4 5 4 3 4 3 2 1 2 3 4
His maxinun speed was 5 near the beginning of meter 4.
[Standard input ]
Line 1: Two space-separated integers : L and N
Line 2—N+1: Line i+1 describes turn i with two space-separated integer: T-i and S-i
[Standard output ]
Line
1:A single integer, representing the maximum speed which Dr.kong can attain
between the start and the finish line , inclusive.
[Sample input] [Sample output]
14 3 7 1 11 1 13 8
5
[ T8 ]
SECRET
Dr.kong is constructing a new machine and wishes to keep it secret as long as possible .He has hidden in it deep within some forest and needs to be the machine during its construction . He has a secret tunnel that he uses only for the return trips .
The forest comprises N(2<=N<=200) landmarks (numbered 1…N) connected by P (1<=P<=40000) bidirectional trails (numbered 1…P) and with a positive length that does not exceed 1000,000. Multiple trails might join a pair of landmarks/
To minimize his chances of detection , Dr.kong knows he cannot use any trail on the forest more than once and that he should try to use the shorest trails.
Help Dr.kong get from the entrance ( landmark 1) to the secret machine (landmark N) a total of T times . Find the minimum possible length of the longest single trail that he will have to use , subject to the constraint that he use no trail more than once .
(Note well: The foal is to minimize the length of the longest trail ,not the trail lengths.) It is guaranteed that Dr.kong can make all T trips without reusing a trail.
[Standard input ]
Line 1:Three space-separated integers: N, P,and T
Line 2:Line i+1 contains three space-separated integers, A_i, B_i, and L_i.
[Standard ouuput]
Line 1: A single integer that is the minimum possible length of the longest segment of Dr,kong‘s route
[Sample input]
7 1 2 3 1 4 4 5 1 6
9 2 3 7 4 3 5 7 6 7
2 2 5 5 1 1 7 1 3 3
[Sample output]
5
第五届河南省大学生程序设计竞赛
【 T1 】
奇怪的排序
最近,Dr. Kong 新设计一个机器人Bill。这台机器人很聪明,会做许多事情。惟独对自然数的理解与人类不一样,它是从右往左读数。比如,它看到123时,会理解成321。让它比较23与15哪一个大,它说15大。原因是它的大脑会以为是32与51在进行比较。再比如让它比较29与30,它说29大。
给定Bill两个自然数A和B,让它将 [A,B] 区间中的所有数按从小到大排序出来。你会认为它如何排序? 【标准输入】
第一行: N 表示有多少组测试数据。
接下来有N行, 每一行有两个正整数A B 表示待排序元素的区间范围。 【标准输出】
对于每一行测试数据,输出一行,为所有排好序的元素,元素之间有一个空格。
【约束条件】
2<=N<=5 1<=A<=B<=200000 B-A<=50。
【 样 例 】 标准输入 2 8 15 22 39
标准输出 10 8 9 11 12 13 14 15 30 31 22 32 23 33 24 34 25 35 26 36 27 37 28 38 29 39 【 T2 】
最强DE 战斗力
春秋战国时期,赵国地大物博,资源非常丰富,人民安居乐业。但许多国家对它虎视眈眈,准备联合起来对赵国发起一场战争。
显然,面对多个国家的部队去作战,赵国的兵力明显处于劣势。战斗力是决定战争成败的关键因素,一般来说,一支部队的战斗力与部队的兵力成正比。但当把一支部队分成若干个作战队伍时,这个部队的战斗力就会大大的增强。
一支部队的战斗力是可以通过以下两个规则计算出来的:
1.若一支作战队伍的兵力为N,则这支作战队伍的战斗力为N;
2.若将一支部队分为若干个作战队伍,则这支部队的总战斗力为这些作战队伍战斗力的乘积。
比如:一支部队的兵力为5时的战斗力分析如下:
情况 1 2 3 4 5 6 7 【标准输入】
第一行: N 表示有N组测试数据。 (2<=N<=5)
接下来有N行,每行有一个整数Ti 代表赵国部队的兵力。 (1 <= Ti <= 1000)i=1,?N 【输【标准输出】
作战安排 1,1,1,1,1(共分为5个作战队伍) 1,1,1,2 (共分为4个作战队伍) 1,2,2 (共分为3个作战队伍) 1,1,3 (共分为3个作战队伍) 2,3 (共分为2个作战队伍) 1,4 (共分为2个作战队伍) 5 (共分为1个作战队伍) 总的战斗力 1*1*1*1*1=1 1*1*1*2=2 1*2*2=4 1*1*3=3 2*3=6 1*4=4 5=5 显然,将部队分为2个作战队伍(一个为2,另一个为3),总的战斗力达到最大!