编程介的小学生 2017-05-08 15:32 采纳率: 20.5%
浏览 743
已采纳

Gear Set

A group of gears is defined as a set of 2-dinemsional disks with the teeth being ignored. Each gear can only rotate either clockwise or anti-clockwise according to a fixed axes. The gears are not overlapping each other. If one gear is rotating clockwise, then another one which is tangent to it will rotate anti-clockwise, and vice versa. Here we assume that the gears will never skid.

Given the centers and radiuses of n gears which are indexed from 1 to n. One questions is: will the n-th gear be driven by the 1st gear if we rotate the 1st one clockwise?

In Figure 1, the 1st gear is stuck so it cannot be rotated at all. In Figure 2, the n-th (3rd) gear is not tangent to any of the other gears and hence will not be driven by the 1st one.

If it is possible to drive gear n by gear 1, then let us rotate gear 1 clockwise with a steady speed. Assume that there is a worm initially sticking at the left-most point (the 2-D point with the smallest x coordinate) on gear 1. When the worm is driven to a tangent point to another gear, it can jump to the other gear or stay where it is. What is the minimum distance that worm must travel, if it is to reach the right-most point on gear n? Please keep in mind that the worm can be driven by a gear only, not by itself.

Input

The input consists of several test cases. In each test case:

the first line contains an integer n (2 <= n <= 20), which is the number of gears;

and the following n lines gives the information of the n gears, each occupies one line. To be more specific, in the i-th line, there are xi and yi, the coordinates of the i-th disk center, and the radius ri of the i-th disk.

Note:

xi, yi, and ri are all floating point numbers.

Two disks (x1, y1, r1) and (x2, y2, r2) are considered to be tangent to each other, if fabs(r1 + r2 - dist) < 1e-5, where dist is the distance between their centers.

The input is finished by n = -1.

Output

For each test case, if gear n cannot be driven by gear 1, print "Wrong combination"; otherwise print the minimum distance that the worm must move, up to 3 decimal places.

Sample Input

3
0 0 1
2 0 1
1 1.7320508 1
4
0 0 1
2 0 1
0 2 1
2 2 1
-1

Sample Output

Wrong combination
6.283

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。