第一 Humidex
Time Limit:1000MS Memory Limit:65536K
Total Submit:765 Accepted:132
Description
Adapted from Wikipedia, the free encyclopedia
The humidex is a measurement used by Canadian meteorologists to reflect the combined effect of heat and humidity. It differs from the heat index used in the United States in using dew point rather than relative humidity.
When the temperature is 30 C (86 F) and the dew point is 15 C (59 F), the humidex is 34 (note that humidex is a dimensionless number, but that the number indicates an approximate temperature in C). If the temperature remains 30 C and the dew point rises to 25 C (77 F), the humidex rises to 42.3.
The humidex tends to be higher than the U.S. heat index at equal temperature and relative humidity.
The current formula for determining the humidex was developed by J.M. Masterton and F.A. Richardson of Canada's Atmospheric Environment Service in 1979.
According to the Meteorological Service of Canada, a humidex of at least 40 causes "great discomfort" and above 45 is "dangerous." When the humidex hits 54, heat stroke is imminent.
The record humidex in Canada occurred on June 20, 1953, when Windsor, Ontario hit 52.1. (The residents of Windsor would not have known this at the time, since the humidex had yet to be invented.) More recently, the humidex reached 50 on July 14, 1995 in both Windsor and Toronto.
The humidex formula is as follows:
humidex = temperature + h
h = (0.5555)*(e - 10.0)
e = 6.11 * exp [5417.7530 * ((1/273.16) - (1/(dewpoint+273.16)))]
where exp(x) is 2.718281828 raised to the exponent x.
While humidex is just a number, radio announcers often announce it as if it were the temperature, e.g. "It's 47 degrees out there ... [pause] .. with the humidex,". Sometimes weather reports give the temperature and dewpoint, or the temperature and humidex, but rarely do they report all three measurements. Write a program that, given any two of the measurements, will calculate the third.
You may assume that for all inputs, the temperature, dewpoint, and humidex are all between -100 C and 100 C.
Input
Input will consist of a number of lines. Each line except the last will consist of four items separated by spaces: a letter, a number, a second letter, and a second number. Each letter specifies the meaning of the number that follows it, and will be either T, indicating temperature, D, indicating dewpoint, or H, indicating humidex. The last line of input will consist of the single letter E.
Output
For each line of input except the last, produce one line of output. Each line of output should have the form:
T number D number H number
where the three numbers are replaced with the temperature, dewpoint, and humidex. Each value should be expressed rounded to the nearest tenth of a degree, with exactly one digit after the decimal point. All temperatures are in degrees celsius.
Sample Input
T 30 D 15
T 30.0 D 25.0
E
Sample Output
T 30.0 D 15.0 H 34.0
T 30.0 D 25.0 H 42.3
第二 Tour de France
Time Limit:1000MS Memory Limit:65536K
Total Submit:217 Accepted:58
Description
A racing bicycle is driven by a chain connecting two sprockets. Sprockets are grouped into two clusters: the front cluster (typically consisting of 2 or 3 sprockets) and the rear cluster (typically consisting of between 5 and 10 sprockets). At any time the chain connects one of the front sprockets to one of the rear sprockets. The drive ratio -- the ratio of the angular velocity of the pedals to that of the wheels -- is n:m where n is the number of teeth on the rear sprocket and m is the number of teeth on the front sprocket. Two drive ratios d1<d2 are adjacent if there is no other drive ratio d1<d3<d2. The spread between a pair of drive ratios d1<d2 is their quotient: d2/d1. You are to compute the maximum spread between two adjacent drive ratios achieved by a particular pair of front and rear clusters.
Input
Input consists of several test cases, followed by a line containing 0. Each test case is specified by the following input:
f: the number of sprockets in the front cluster;
r: the number of sprockets in the rear cluster;
f integers, each giving the number of teeth on one of the gears in the front cluster;
r integers, each giving the number of teeth on one of the gears in the rear cluster.
You may assume that no cluster has more than 10 sprockets and that no gear has fewer than 10 or more than 100 teeth.
For each test case, output the maximum spread rounded to two decimal places.
Output
Sample Input
2 4
40 50
12 14 16 19
0
Sample Output
1.19
第三 Life Forms
Time Limit:5000MS Memory Limit:65536K
Total Submit:27 Accepted:2
Description
You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial traits such as height, colour, wrinkles, ears, eyebrows and the like. A few bear no human resemblance; these typically have geometric or amorphous shapes like cubes, oil slicks or clouds of dust.
The answer is given in the 146th episode of Star Trek - The Next Generation, titled The Chase. It turns out that in the vast majority of the quadrant's life forms ended up with a large fragment of common DNA.
Given the DNA sequences of several life forms represented as strings of letters, you are to find the longest substring that is shared by more than half of them.
Standard input contains several test cases. Each test case begins with 1 ≤ n ≤ 100, the number of life forms. n lines follow; each contains a string of lower case letters representing the DNA sequence of a life form. Each DNA sequence contains at least one and not more than 1000 letters. A line containing 0 follows the last test case.
For each test case, output the longest string or strings shared by more than half of the life forms. If there are many, output all of them in alphabetical order. If there is no solution with at least one letter, output "?". Leave an empty line between test cases.
Input
Output
Sample Input
3
abcdefg
bcdefgh
cdefghi
3
xxx
yyy
zzz
0
Sample Output
bcdefg
cdefgh
第四 Rinse
Time Limit:1000MS Memory Limit:65536K
Total Submit:3 Accepted:1
Description
Granny's reunion was a smashing success. Next she is expecting a visit from Eliot Ness and in anticipation of his visit would like to remove as much whiskey from the cream can as possible prior to his visit.
Granny can upend the cream can, thus pouring its contents on the ground. But due to surface tension and the shape of the can a small amount of the content remains, even after the can is upended. Granny has a barrel full of rain water that she can use to rinse the can several times. Each rinse involves pouring some amount of water (perhaps none) into the cream can, mixing it thoroughly with the existing contents, and pouring it out. After each rinse an amount of liquid remains, some fraction of which is whiskey and the rest water.
Mr. Ness' visit is imminent, affording Granny the time to do at most k rinses. You are to determine a rinsing strategy that Granny should employ to minimize the amount of residual whiskey in the cream can after the last rinse.
Standard input consists of several test cases. Each test case is represented by a line with five numbers:
0 < k ≤ 100 -- an integer denoting the maximum number of rinses
Vb > 0 -- a real number denoting the volume of available rain water in the barrel
Vw > 0 -- a real number denoting the volume of whiskey in the cream can
Vr > 0 -- a real number denoting the volume of liquid that cannot be poured out by upending the can (further liquid might be eliminated by evaporation, but there is insufficient time before Ness' visit for any evaporation to take place)
Vc > Vw,Vr -- a real number denoting the maximum capacity of the cream can.
A line containing 0 follows the last case. For each test case, output r, the number of rinses that Granny should perform. On the same line, output r real numbers, rounded to two decimal places, giving the amount of rain water to be used for each rinse, in order.
Note that the total amount of water used in all rinses must not exceed Vb. The total amount of liquid in the cream can cannot exceed Vc at any time. Assume that whiskey and water mix perfectly and that their volumes are additive; that is, x units of whiskey and y units of water combine to form x+y units of liquid.
Input
Output
Sample Input
2 15.0 25.0 1.0 50.0
0
Sample Output
2 0.00 15.00
第五 Ferry Loading IV
Time Limit:1000MS Memory Limit:65536K
Total Submit:37 Accepted:5
Description
Before bridges were common, ferries were used to transport cars across rivers. River ferries, unlike their larger cousins, run on a guide line and are powered by the river's current. Cars drive onto the ferry from one end, the ferry crosses the river, and the cars exit from the other end of the ferry.
There is an l-meter-long ferry that crosses the river. A car may arrive at either river bank to be transported by the ferry to the opposite bank. The ferry travels continuously back and forth between the banks so long as it is carrying a car or there is at least one car waiting at either bank. Whenever the ferry arrives at one of the banks, it unloads its cargo and loads up cars that are waiting to cross as long as they fit on its deck. The cars are loaded in the order of their arrival; ferry's deck accommodates only one lane of cars. The ferry is initially on the left bank where it broke and it took quite some time to fix it. In the meantime, lines of cars formed on both banks that await to cross the river.
The first line of input contains c, the number of test cases. Each test case begins with l, m. m lines follow describing the cars that arrive in this order to be transported. Each line gives the length of a car (in centimeters), and the bank at which the car arrives ("left" or "right").
For each test case, output one line giving the number of times the ferry has to cross the river in order to serve all waiting cars.
Input
Output
Sample Input
4
20 4
380 left
720 left
1340 right
1040 left
15 4
380 left
720 left
1340 right
1040 left
15 4
380 left
720 left
1340 left
1040 left
15 4
380 right
720 right
1340 right
1040 right
Sample Output
3
3
5
6
第六 数n的K划分
Time Limit:1000MS Memory Limit:65536K
Total Submit:26 Accepted:2
Description
将整数n分成k份,且每份不能为空,任意两份不能相同(不考虑顺序)。
例如:n=7,k=3,下面三种分法被认为是相同的。
1,1,5; 1,5,1; 5,1,1;
问有多少种不同的分法。
Input
n,k (6<n<=200,2<=k<=6)
Output
一个整数,即表示有多少种不同的分法。
Sample Input
7 3
Sample Output
4
Hint
输入: 7 3
输出:4 {四种分法为:1,1,5;1,2,4;1,3,3;2,2,3;}
Source
第七 中缀表达式求值
Time Limit:1000MS Memory Limit:65536K
Total Submit:4 Accepted:0
Description
表达式一般由操作数(Operand)、运算符(Operator)和界限符(delimiter)组成。操作数可以是常数、变量或常量标识符。运算符分为算术运算符、关系运算符和逻辑运算符。基本界限符有左右括号和表达式结束符号。为了叙述简单,我们仅讨论简单算术表达式的求值问题。这种表达式只含加、减、乘、除四种运算符,并以等号作为结束符。
算法基本思想:
(1) 建立两个栈:一个是操作数栈OpndStack,用来寄存操作数或运算结果;另一个是运算符栈OptrStack,用来寄存运算符和界限符。
(2) 依次读入表达式中的字符,若是操作数则压进操作数栈OpndStack;若是运算符,则与运算符栈OptrStack的栈顶元素比较优先级,根据比较的结果作相应的操作。
有括号时,按照先括号内、后括号外的规则,遇到左括号时,表明子表达式(括号内的表达式)求值开始;遇到右括号时,要求完成子表达式的求值,即依次弹出运算符栈中的元素,直到遇见与之匹配的左括号为止。要划分子表达式,左括号应压进运算符栈OptrStack,因此在进栈以前,左括号的优先级最高。左括号进栈之后,为了按规则计算子表达式,它的优先级又要比所有运算符低。为此,我们给每个运算符定义了两个优先级:一是读入优先级(在读入时的优先级),二是栈优先级(入栈之后的优先级)。左括号读入优先级最高,栈优先级最低。
当读入一个运算符或界限符时,首先需要给它配备两个优先级,产生一个运算符栈的元素,这项任务由下面定义的函数MathOptr完成。然后与运算符栈的栈顶元素比较,如果前者的“读入优先级”不高于后者的“栈优先级”,则弹出运算符栈顶元素,执行一次运算,这项工作由函数Evaluate承担。
中缀表达式求值:函数Infix用于模拟算术表达式的求值过程。算法:
1.两个栈:操作数栈OpndS,用于寄存操作数或运算结果;操作符栈OptrS,用来寄存运算符和定界符。DataType和DataType1分别为两栈中数据类型。
2.依次读入字符,操作数压进OpndS;运算符则与OptrS的栈顶元素比较,根据结果做相应操作。
有关问题详细描述可参看《数据结构》
Input
输入包括多个测试用例,每个测试用例一行,由#开始,#号结束。
Output
对每个测试用例,表达式正确时输出表达式的值,表达式错误时,输出"Expression Error!"。每个输出用例占一行,计算结果保留2位小数。
Sample Input
#(23.0+56.0*3.0)/56.0+56.0*36.0#
#(-23.0+56.0*3.0)/56+56*36#
#(-23.0+56.0*3.0)/56.0+56.0*36.0)#
Sample Output
2019.41
2018.59
第九 How many rabbits?
Time Limit:1000MS Memory Limit:65536K
Total Submit:374 Accepted:69
Description
The rabbits have powerful reproduction ability. One pair of adult rabbits can give birth to one of pair of kid rabbits every moth.And after m months,the kid rabbits can become adult rabbits.
As we all know, when m=2,the sequence of the number of pairs of rabbits in each month is called Fibonacci sequence.But when m<>2, the problem seems not so simple. You job is to calculate after d months, how many pairs of the rabbits are there if there is excactly one pair of adult rabbits initially.You may assume that none of the rabbits dies in this period.
Input
The input may have multiple test case.In each test case,there is one line having two integers m(1<=m<=10) ,d(1<=d<=100),
m is number of months after which kid rabbits can becomes adult rabbits, and d if the number of months after which you should calculate the number of pairs of rabbits.The input will be terminated by m=d=0.
Output
You muxt print the number of pairs of rabbits after d months, one integer per line.
Sample Input
2 3
3 5
0 0
Sample Output
5
9
Hint
第十 阶乘有多大?
Time Limit:1000MS Memory Limit:65536K
Total Submit:578 Accepted:108
Description
笨笨已经会编程计算机10以内的阶乘了,现在有人请他帮忙计算一下S=1!+2!+3!+…+n!(n≤50)其中“!”表示阶乘。他用原来的办法算来算去总是得不到正确结果。你能帮帮他,让他的程序AC吗?
Input
输入正整数N。
Output
输出结果S。
Sample Input
6
Sample Output
873
十一 Get Ready?
Time Limit:1000MS Memory Limit:32767K
Total Submit:702 Accepted:260
Description
Is this your first times participating in this kind of contest? I think most of you will answer "YES". So let's do this problem as warm-up and check whether the IMNU-OJ work properly.
Now, we will give you the information of some contest that are just like the one you are taking. Your task is to output their rank lists according to the contes rules you have already understood.
Input
There is only one number C(C≤100) in the first line of the input, which is the number of contest.
For each contes,the first line contains only one number N indicating the total number of teams. And then follow N lines.Each line has three numbers Ti,Si and Pi(1≤Ti≤N,0≤Si≤20,0≤Pi≤10000).which stand for the ID,score and Penalty of the ith team of the contest respectively. Specially, all teams' scores are distinct.
Output
for each contest, you should output the rank list(team ID) in descent order in just one line.Numbers separate exactly one space.
Sample Input
2
3
3 2 200
2 1 100
1 3 300
2
1 2 222
2 1 222
Sample Output
1 3 2
1 2
十二
Description
The first Annual IMCPC was held in the new Campus of Inner Mongolia University last year.And now we gather again for jaunting in the same wonderful place. After jaunting, most of participants will probably have a jaunt around the beautiful Campus.
As you have seen,the main attraction of this place is the green hills surrounding. And a problem comes up now. What is the area of cross section of the hills?
This range of hills contains peaks and valleys.So before calculating the area, we have to firstly scale and write down the coordinates of the turning points. In the following gragh, 7 turning points of a hill are marked.
Input
The first line of the input is a positive integer T. T is the number of the test cases followed.
The first line of each test cases contains only one positive integer N(1<N<=1000) which represents the number of the turning points. Then N lines follow and the ith line contains two nonnegative integers Xi(0<=Xi<=10000),Yi(0<=Yi<=10000) which represent the coordinate of the ith turning point. It is assumed that the given turning points is in X-coordinate increasing order,i.e.Xi<Xj when i<j.
Output
The output of the program should consist of one line of ouput for each test case. The output of each test case only contains one real number which represents the area of the cross section of the hills.The real numbers are rounded to one decimal digit. No redundant spaces are needed.
Sample Input
2
2
1 4
3 4
2
2 7
3 9
Sample Output
8.0
8.0
。