问题 1019. -- 2011市赛题：Fiber
1019: 2011市赛题：Fiber时间限制: 1 Sec 内存限制: 128 MB
提交: 6 解决: 6
Today,here's a interesting problem.
Nowadays , optical fiber(光纤) is widely used in our life.Fiber Transmission (光纤传输) is the method to send optical information (光信息)in a spacial pipe,as the figure shows.
The light goes into the pipe at the left end of the pipe,then after some times direct reflection,goes out the pipe at the right end , to send optical message.
Here's the problem, when the light goes into the pipe in a given direction ,which direction will it be when it goes out the pipe.
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. (T <= 100)
Each test case start with two positive integers D , L , which indicate the diameter of pile and the lenth of the pipe.(that is to say the pipe is between Y = D , Y = 0,X = 0,and X = L).next lines follow three integers,h,Vx,Vy.represents the position and direction in which the light goes into the pipe,the position is (0,h) and the direction is vector (Vx,Vy). All numbers in the input is in the range of int32.(D>= h>= 0,D > 0,L > 0,Vx > 0,Vy != 0.we ensure that the light can goes into the pipe in the given direction and position.)
Output two integers Vx2 , Vy2 represent the direction vector in which the light goes out the pipe.because of the various way to present that direction,we need you make Abs(Vx) == Abs(Vx2).
2 1 -1
2 1 -1
1 1 -1
因为方向和速度大小是无关的.可假设X方向速度为Vx.则在管道内的总时间为W /Vx,那么在Y方向上的总路程是L = W / Vx * Vy;则问题转化为从开始位置出发,结果L的路程,在Y方向上碰撞了几次.当然不用土土的模拟,只要判断L里有几个H就行了.当然要注意处理初试高度和一些边界情况.