HBC24733单词记忆方法,排序,递归,归并[USACO 2010 Mar S]Need For Speed题解

人生如戏 算法基础篇 57 0
题库丰富多样,涵盖各个领域,全网最全C++题库,让您在练习中不断成长!
Bessie is preparing her race car for the upcoming Grand Prix, but she wants to buy some extra parts to improve the car's performance. Her race car currently has mass M (1

Bessie is preparing her race car for the upcoming Grand Prix, but she wants to buy some extra parts to improve the car's performance. Her race car currently has mass M (1 <= M <= 1,000) and is able to push itself forward with a force of F (1 <= F <= 1,000,000). The Race Car Performance Store has N (1 <= N <= 10,000) parts conveniently numbered 1..N. Bessie can buy as many or as few parts as she wishes though the store stocks no more than one instance of each part. Part P_i P i ​ adds force F_i F i ​ (1 <= F_i F i ​ <= 1,000,000) and has mass M_i M i ​ (1 <= M_i M i ​ <= 1,000). Newton's Second Law decrees that F = MA, where F is force, M is mass, and A is acceleration. If Bessie wants to maximize the total acceleration of her race car (and minimize the mass otherwise), which extra parts should she choose? Consider a race car with initial F=1500 and M=100. Four parts are available for enhancement: i F_i M_i 1 250 25 2 150 9 3 120 5 4 200 8 Adding just part 2, e.g., would result in an acceleration of (1500+150)/(100+9) = 1650/109 = 15.13761. Below is a chart of showing the acceleration for all possible combinations of adding/not-adding the four parts (in column one, 1=part added, 0=part not added): Parts Aggregate Aggregate 1234 F M F/M 0000 1500 100 15.0000 0001 1700 108 15.7407 0010 1620 105 15.4286 0011 1820 113 16.1062 0100 1650 109 15.1376 0101 1850 117 15.8120 0110 1770 114 15.5263 0111 1970 122 16.1475 <-- highest F/M 1000 1750 125 14.0000 1001 1950 133 14.6617 1010 1870 130 14.3846 1011 2070 138 15.0000 1100 1900 134 14.1791 1101 2100 142 14.7887 1110 2020 139 14.5324 1111 2220 147 15.1020 Thus, the best additional part combination is parts 2, 3, and 4.

HBC24733单词记忆方法,排序,递归,归并[USACO 2010 Mar S]Need For Speed题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
全网最全C++题库,助您挑战自我,突破极限,成为编程领域的佼佼者!

标签: HBC24733单词记忆方法 排序 递归 归并[USACO 2010 Mar S]Need For Speed题解