当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3128:What is the air speed velocity…

题目描述
What is the air speed velocity…



…of a fully laden swallow? This fearful question was posed to the intrepid band of Grail searchers.Their response of "African or European?" was partly correct.The air speed would most definitely depend on the sub-species of swallow. King Arthur, fearing more intense questioning in this vein,ordered his royal mathematicians to determine the air speed of a fully laden swallow - both African and European.

The mathematicians called upon the royal birders to capture a number of swallows of both types, lade them fully, and then release them from point A and time their arrival at point B.Since they didn't want to confuse their figures, the European and African swallows were each started from a different location, so that each group flew a different distance, but all swallows in the same group flew the same distance. They then asked the royal map-makers to determine the distance (measured in furlongs) between the two starting points and the finish point. Using 10 swallows of each type, the royal mathematicians would then compute the average air speed for each group.

However, the royal mathematicians were somewhat lazy. After gathering all the data, they decided it was MUCH too hard to do all those nasty calculations by hand. So, they quickly constructed a time machine and have come into the future to enlist your help: they need you to write a program to do the calculations, which they will then take back into the past with them. Thus the searchers of the Grail will be saved from certain doom, (should this dastardly question be posed again), and you will go down in history as a hero. (Well, maybe not history, since they are from the past, so maybe you'll go down in futurory?)

There's one tricky bit (you knew it was coming): the royal mathematicians cannot agree on exactly how the average should be calculated. Some believe that, for each group, one should add up all of the times and then divide the total distance covered by all the swallows of that type by the total time (this is method 1). Others are of the opinion that the average speed is determined by computing the speed for each swallow, summing those values and then dividing that total by the total number of swallows (this is method 2). Your program should compute the average both ways, to avoid a nasty falling out among the royal mathematicians.

The input provided by the royal mathematicians is somewhat disorganized - the two breeds'times have been intermixed and they weren't too careful about capitalization. But each entry is on a separate line and marked with an 'A' or 'a' or 'E' or 'e' to aid in identification. Each line begins with this single letter, followed by a single space. The final datum on the line is the elapsed time the swallow flew, expressed in hours. Since the time-keeping of the era wasn't very accurate, this value is simply a real number (>0) with a single level of precision, such as 1.5 (one and a half hours), or 0.4 (four-tenths of an hour).
输入解释
The very first line of the input file will consist of 2 integers, both greater than 0, separated by a single space. The first integer is the distance the African swallows flew and the second integer is the distance the European swallows flew. Next come the times for the swallows (20 lines total: 10 for African, 10 for European - NOT in this order). Thus the input file has a total of 21 lines.
输出解释
The format for the output should be grouped by methods, with Method 1 being displayed first.
Each method will produce 3 lines of output:
  • Line 1: the name of the method (capitalized, with a digit identifying it), e.g. "Method 1"(the quotes are not part of your output.)

  • Line 2: the speed of a fully-laden African swallow (expressed in furlongs per hour),e.g. "African: 3.00 furlongs per hour" (the quotes are not part of your output.)

  • Line 3: the speed of a fully-laden European swallow (expressed in furlongs per hour),e.g. "European: 3.00 furlongs per hour" (the quotes are not part of your output.)

The format for the data for each method is as follows:
  • The full name of the breed of swallow (capitalized), beginning with African

  • A colon

  • A single space

  • The speed (to two digits of accuracy, with leading 0 for values < 1.0)

  • A single space

  • The phrase "furlongs per hour" (the quotes are not part of the output).

See the Sample output section below for any clarifications you require.
输入样例
6 5
a 1.0
A 1.0
E 2.0
E 2.0
A 1.0
e 2.0
a 1.0
A 1.0
E 2.0
E 2.0
A 1.0
e 2.0
a 1.0
A 1.0
E 2.0
E 2.0
A 1.0
e 2.0
e 1.0
a 2.0
输出样例
Method 1
African: 5.45 furlongs per hour
European: 2.63 furlongs per hour
Method 2
African: 5.70 furlongs per hour
European: 2.75 furlongs per hour
来自杭电HDUOJ的附加信息
Recommend chenrui

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3128

最后修改于 2020-10-25T23:00:19+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)