所有题目时间限制:1秒【T1】序号互换Dr.Kong 设计了一个聪明的机器人卡多,卡多会对电子表格中的单元格坐标快速计算出来。
单元格的行坐标是由数字编号的数字序号,而列坐标使用字符序号。
观察字母序号,发现第1列到第26列的字母序号分别为A,B,……,Z,接着,第27列序号为AA,第28列为AB,以此类推。
若给Dr.Kong的机器人卡多一个数字序号(比如32),它能很快算出等价的字母序号(即AF),若给机器人一个字母序号(比如AA),它也能很快算出等价的数字序号(27),你能不能与卡多比试比试,看谁能算得更快更准。
【标准输入】第一行:N 表示有多少组测试数据。
接下来N行,每行或者是一个正整数,或者是一个仅由大写字母组成的字符串。
【标准输出】对于每一行测试数据,输出一行。
如果输入为一个正整数序号,则输出等价的字母序号;如果输入为字符串,则输出等价的数字序号。
【约束条件】输入保证,所有数字序号和字母序号对应的数字序号均<=2*10^9【样例】【T2】节能Dr.kong 设计的机器人卡多越来越聪明。
最近市政府公司交给卡多一项任务,每天早晨5:00开始,它负责关掉ZK大道右侧上的所有路灯。
卡多每到早晨5:00准会在ZK大道上某盏灯的旁边,然后他开始关灯。
每盏灯都有一定的功率,机器人卡多有自觉的节能意识,它希望在关灯期间,ZK大道右侧上所有的路灯的耗电总量数是最少的。
机器人卡多以1m/s的速度行走。
假设关灯动作不需要花费额外的时间,因为当它通过某盏路灯时就顺手将灯关掉。
请编写程序,计算在给定路灯设置,灯泡功率以及机器人卡多的起始位置的情况下,卡多关灯期间,Zk大道上所有灯耗费的最小能量。
【标准输入】第一行N 表示ZK大道右侧路灯的数量(2<=N<=1000)第二行V 表示机器人卡多开始关灯的路灯号。
(1<=V<=N)接下来的N行中,每行包含两个空格隔开的整数D和W,用来描述每盏灯的参数D表示该路灯与ZK大道起点的距离(用米为单位来表示)W表示灯泡的功率,即每秒该灯泡所消耗的能量数。
路灯是按顺序给定的。
(0<=D<=1000,0<=W<=1000)【标准输出】输出一个整数,即消耗总能量之和的最小值。
注意结果小于200,000,000【样例】【T3】表达式求值Dr.Kong 设计的机器人卡多掌握了加减运算以后,最近又学会了一些简单的函数求值,比如,它知道函数min(20,23)的值是20,add(10,98)的值是108等等。
经过训练,Dr.Kong设计的机器人卡多甚至会计算一种嵌套的更复杂的表达式。
假设表达式可以简单定义为:1.一个正的十进制数x是一个表达式。
2.如果x和y是表达式,则函数min(x.y)也是表达式,其值为x,y中最小的数。
3.如果x和y是表达式,则函数max(x,y)也是表达式,其值为x,y中最大数。
4.如果x和y是表达式,则函数add(x,y)也是表达式,其值为x,y之和。
例如,表达式max(add(1,2),7)的值为7.请编写程序,对给定的一组表达式,帮助DrKong算出正确答案,以便校队卡多计算的正误。
【标准输入】第一行:N 表示要计算的表达式的个数(1<=N<=10)接下来有N行,每行是一个字符串,表示待求值的表达式(表达式中不会有多余的空格,每行不超过300个字符,表达式中出现的十进制数都不超过1000.)【标准输出】输出有N行,每行对应一个表达的值。
【样例】【T4】走迷宫DrKong设计的机器人卡多非常爱玩,它常常偷偷跑出实验室,在某个游乐场玩之不疲。
这天卡多又跑出来了,在SJTL游乐场玩个不停,坐完碰碰车,又玩滑滑梯,这时卡多又走入了一个迷宫。
整个迷宫是用一个N*N的方阵给出,方阵中单元格中填充了一个整数,表示走到这个位置的难度。
这个迷宫可以向上,向下,向左,向右走,但不能穿越对角线。
走迷宫的取胜规则很有意思,看谁能更快地找一条路径,其路径上的单元格最大难度与最小难度之差是最小的。
当然了,或许这样的路径不是最短的。
机器人卡多现在在迷宫的左上角(第一行,第一列)而出口在迷宫的右下角(第N行,第N列)。
卡多很聪明,很快就找到了这样的一条路径。
你能找到吗?【标准输入】第一行:N 表示迷宫是N*N的方阵(2<=N<=100)接下来N行,每行包含N个整数,用来表示每个单元格中的难度(0<=任意难度<=120)【标准输出】输出为一行整数,表示路径上的难度与最低难度的差。
【样例】提示:样例中粗斜体数字为机器人卡多选择的路径。
【T5】宝物传说HMH大沙漠中有一个迷宫,里面藏有许多宝物。
迷宫里可能有N个藏宝地点,用1到N标记。
藏宝地点之间最多有一条通路相连。
标记为1为迷宫的进出口。
某天,DrKong找到了迷宫的地图,他已经知道其中K(1<=K<=N)个不同的地点真的藏有宝物。
Drkong 决定让他的机器人卡多去探险。
卡多在经过某个藏宝地点时可能会拿走宝物。
但它每拿走一个藏宝地点的宝物后,它的载重量会增加W。
迷宫中的通路是不平坦到处是陷阱。
假设每条通路都有一个危险度,其值与通过此路的载重量成正比。
当机器人卡多进入迷宫时,它的载重量为0,。
只有当卡多携带宝物的载重量不大于某个通路的危险度时,它才能顺利通过此路,否则就会掉下陷阱,不能出来。
Drkong希望他的机器人卡多尽量多带出宝物,当然他更希望卡多最后能从标记1的地点出来。
请编写程序,帮助Drkong计算一下,卡多最多能带出多少个藏宝地点的宝物。
【标准输入】第一行:NMKW接下来K行,每行一个整数,表示有藏有宝物的地点标号。
在接下来M行,每行三个整数X,Y,Z,表示地点X与地点Y之间有一条危险度为Z的通路。
【标准输出】输出一个整数,表示卡多最多能带出的宝物的堆数。
【约束条件】1<=N<=8000 1<=K<=N 1<=M<=15000 1<=W,Z<=10000数据保证所有的地点之间都是有道路可以到达的。
提示:机器人卡多经过一个宝藏地点是可以不拿走宝物,而且同一宝藏的点可以经过多次。
【样例】SUBSTRINGYou 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]3ABCABAXYZXCVCX[Sample Output]ABAXXCVCX[ T7 ]BOBSLEDDINGDr.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 beenter 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 14Spd: 1 2 3 4 4 5 4 3 4 3 2 1 2 3 4His maxinun speed was 5 near the beginning of meter 4.[Standard input ]Line 1: Two space-separated integers : L and NLine 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 57 111 113 8[ T8 ]SECRETDr.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 TLine 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] [Sample output]7 9 2 51 2 22 3 53 7 51 4 1 4 3 14 5 75 7 1 16 3 67 3。