求救~ 北大ACM题

erick08 2009-09-12 09:52:50
关键是输出,即后面的Sample Output,能解释的解释下吧!!

Description

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

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.
Output

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.
Sample Input

3
2000
3000
4000
4
2000
2000
1999
2001
5
2000
2000
1999
2001
1999
0


Sample Output

3000

4

1


输出为什么是这样的, 应该怎么想了???
第一次发帖, 希望爱好者帮忙帮忙!!!
先谢了......
...全文
161 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunnywyg 2009-09-18
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 wxsxiaok 的回复:]
但是桌腿多起来的话,还要判断最长的3条桌腿的位置啊。如果3条腿似是挨着的(大于6条腿)这么锯桌子也是不平稳,感觉这道题主要是寻找一种思想找到最优的3条腿~
[/Quote]

这个在理,应该是找3个最优且对立的桌腿
sunnywyg 2009-09-18
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 beyond071 的回复:]
3个脚的桌子 腿长2000、3000、4000,都要锯成2000的才能平稳。所以最少锯掉3000长度
4个脚的桌子 腿长2000、2000、1999、2001,4个脚的桌子要一样长短才能放得稳,所以都锯成1999长度,得锯掉4长度
5个脚的桌子,最少要3个脚一样长度才能平稳,另两个脚不接地也可以平稳(三角形稳定性)。所以都锯成2000,所以只要锯掉1长度
[/Quote]

你不觉得这两句话矛盾么?
四个脚的桌子为什么就不能有个脚不接地?
wxsxiaoK 2009-09-18
  • 打赏
  • 举报
回复
但是桌腿多起来的话,还要判断最长的3条桌腿的位置啊。如果3条腿似是挨着的(大于6条腿)这么锯桌子也是不平稳,感觉这道题主要是寻找一种思想找到最优的3条腿~
beyond071 2009-09-18
  • 打赏
  • 举报
回复
3个脚的桌子 腿长2000、3000、4000,都要锯成2000的才能平稳。所以最少锯掉3000长度
4个脚的桌子 腿长2000、2000、1999、2001,4个脚的桌子要一样长短才能放得稳,所以都锯成1999长度,得锯掉4长度
5个脚的桌子,最少要3个脚一样长度才能平稳,另两个脚不接地也可以平稳(三角形稳定性)。所以都锯成2000,所以只要锯掉1长度
beyond071 2009-09-18
  • 打赏
  • 举报
回复
题目是圆桌,那么重心就是圆心。判断圆心是否在待查三角形内部即可
beyond071 2009-09-18
  • 打赏
  • 举报
回复
判定准则:只要多边形桌子的重心落在三角形内部,桌子就不会摇动
beyond071 2009-09-18
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 sunnywyg 的回复:]
引用 3 楼 beyond071 的回复:
3个脚的桌子 腿长2000、3000、4000,都要锯成2000的才能平稳。所以最少锯掉3000长度
4个脚的桌子 腿长2000、2000、1999、2001,4个脚的桌子要一样长短才能放得稳,所以都锯成1999长度,得锯掉4长度
5个脚的桌子,最少要3个脚一样长度才能平稳,另两个脚不接地也可以平稳(三角形稳定性)。所以都锯成2000,所以只要锯掉1长度


你不觉得这两句话矛盾么?
四个脚的桌子为什么就不能有个脚不接地?
[/Quote]
我不认为这是矛盾的,4个脚的桌子任意取3个脚都是相邻的,所以不行。5个脚的桌子,我说的是最少要3个脚,因为有2个脚可以不接地,所以排列组合中会产生不相邻的三角形
beyond071 2009-09-13
  • 打赏
  • 举报
回复
有意思
hhhcj 2009-09-12
  • 打赏
  • 举报
回复
不明白

64,639

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧