#P1615. [Usaco2008 Mar]The Loathesome Hay Baler麻烦的干草打包机

[Usaco2008 Mar]The Loathesome Hay Baler麻烦的干草打包机

[USACO08MAR] The Loathesome Hay Baler S

题目描述

Farmer John has purchased the world's most loathesome hay baler. Instead of having a drive-roller that drives maybe an idler roller that drives the power take-off for the baler, it has NN rollers (2N1050)(2 \leq N \leq 1050) which drive and are driven by various rollers.

FJ has meticulously cataloged data for each roller i: X_i,Y_i are the center of the roller $(-5000 \leq X_i \leq 5000; -5000 \leq Y_i \leq 5000)$; RiR_i is the roller's radius (3Ri800)(3 \leq R_i \leq 800). The drive-roller is located at (0,0)(0,0); the baler power take-off is located at Xt,YtX_t,Y_t (numbers supplied in the input).

The drive-roller turns clockwise at 10,00010,000 revolutions per hour. Your job is to determine the speeds of all the rollers that are in the power-train: from the drive-roller through the power take-off roller. Rollers that do not transfer power to the take-off roller are to be ignored. A roller of radius Rd that is turning at S rph and driving another roller of radius Rx will cause the second roller to turn at the speed -S*Rd/Rx (where the sign denotes whether the roller is turning clockwise or counterclockwise (anticlockwise for our British friends)).

Determine the power-train path and report the sum of the absolute values of all those rollers' speeds. All the rollers in the input set except the driver-roller are driven by some other roller; power is never transferred to a roller from more than one other roller.

Report your answer as an integer that is the truncated value after summing all the speeds.

Farmer John新买的干草打包机的内部结构大概算世界上最混乱的了,它不象普通的机器一样有明确的内部传动装置,而是,N(2N1050)N (2 \leq N \leq 1050) 个齿轮互相作用,每个齿轮都可能驱动着多个齿轮。 FJ记录了对于每个齿轮 ii,记录了它的 33 个参数:Xi,YiX_i,Y_i 表示齿轮中心的位置坐标 $(-5000 \leq X_i \leq 5000; -5000 \leq Y_i \leq 5000)$;RiR_i 表示该齿轮的半径 (3Ri800)(3 \leq R_i \leq 800)

驱动齿轮的位置为 (0,0)(0,0),并且FJ也知道最终的工作齿轮位于 Xt,YtX_t,Y_t。 驱动齿轮顺时针转动,转速为 10,00010,000 转/小时。你的任务是,确定传动序列中所有齿轮的转速。传动序列的定义为,能量由驱动齿轮传送到工作齿轮的过程中用到的所有齿轮的集合。对能量传送无意义的齿轮都应当被忽略。

在一个半径为 RdRd,转速为 SS 转/每小时的齿轮的带动下,与它相接的半径为 RxRx 的齿轮的转速将为 S×RdRx\frac{-S\times Rd}{Rx} 转/小时。S前的负号的意思是,一个齿轮带动的另一个齿轮的转向会与它的转向相反。

FJ只对整个传动序列中所有齿轮速度的绝对值之和感兴趣,你的任务也就相应转化成求这个值。机器中除了驱动齿轮以外的所有齿轮都被另外某个齿轮带动,并且不会出现 22 个不同的齿轮带动同一个齿轮的情况。

输入格式

Line 1: Three space-separated integers: N,XtN, X_t, and YtY_t

Lines 2..N+1: Line i+1 describes roller i's properties: Xi,YiX_i, Y_i, and RiR_i

输出格式

Line 1: A single integer that is the truncated version of the sum of the absolute value of the speeds of the rollers in the power-train including the drive-roller, all the driven rollers, and the power take-off roller.

样例 #1

样例输入 #1

4 32 54 
0 0 10 
0 30 20 
32 54 20 
-40 30 20

样例输出 #1

20000

提示

Four rollers: the drive-roller at 0,0 with radius 10. It drives the roller above it at 0,30 with radius 20. That roller drives both the power take-off roller at 32,54 (r=20) and a random roller (not in the power train) at -40,30 (r=20).

Roller Radius Speed

1 (0,0) 10 10,000

2 (0,30) 20 -5,000

3 (32,54) 20 5,000


Sum of abs values: 20,000