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

建议使用的浏览器:

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

2628:Table Legs

题目描述
A table with four legs may rock, even on a flat surface, if its legs are not all the same length. Interestingly, regardless of how many legs have differing lengths, it is always possible to saw an amount from some legs so as to make the table sit level on a flat surface without rocking.
Your job is to generalize this approach to a table with many legs equally spaced around the perimeter of a round table. You are to determine the total length of legs to cut so as to have the table sit level without rocking on a flat surface with not necessarily every leg touching the ground.
输入解释
Input consists of data for a number of tables. For each table, a line will give an integer t, between 3 and 50, indicating the number of legs on the table. t subsequent lines will give, in order around the table's circumference, the lengths of the legs in millimetres. Each leg is perpendicular to the table top. A line containing 0 follows the data for the last table.
输出解释
Pick a strategy that cuts the least total length from all legs and print this amount as an integer number. Print a blank line between tables.
输入样例
3
2000
3000
4000
4
2000
2000
1999
2001
5
2000
2000
1999
2001
1999
0

输出样例
3000

4

1


该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2628

最后修改于 2020-10-29T06:37:33+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536