131 - ZOJ Monthly, March 2014 - G
Razor is lightning incarnate. It is a living being, capable only of unleashing it's tremendous electrical power to anything and everything nearby. The only indication of sentience from it is its ability to control its surges, which never seems to actually strike any it would call friend. Like its namesake, it cuts to the bone, with speed and accuracy, sometimes jumping from one thing to another. Its unnatural form gives it speed, and a thirst for blood. It is a force to be reckoned with, and only the strong dare face it.
When Razor uses his super power Plasma Field, he releases a wave of energetic plasma. which grows in power as it extends outwards. Deals damage to enemies both on expansion and on contraction.
In a team battle, Razor used Plasma Field at the beginning. Then he wants to know the number of enemies his skill would hit.
Plasma Field creates a ring of plasma. Let the radius of the ring be R. If Razor released the ring at time t = 0.
When 0 ≤ t ≤ T, R(t) = c*t
When T < t ≤ T*2, R(t) = c * (T * 2 - t).
Before t=0 or after t=2T, the plasma ring does not exist. An enemy is hit by the skill if he is touched by the ring. In other word, "an enemy is hit" means ∃ t∈ [0, 2T], R(t)=d(t), where d(t) is the distance between Razor and the enemy at time t. The ring's center is always Razor. We assume that Razor does not move and all the enemies move at a constant speed in a straight line.
There are multiple test cases. For each test case: The first line are four integers x0, y0, c, T, represent the location of Razor and c(c≥1), T(T≥1) is as described above. The second line is one integer n(n≤1000), represent the number of enemies. Then n lines followed, each line has four integers x, y, vx, vy, represent the emeny’s location at time 0 and the speed of the enemy. All integers' absolute values are not greater than 20000.
For each case, output an integer in a single line, the number of enemies that Plasma Field hit.
0 0 1 1 1 1 1 -1 -1 0 0 1 1 1 1 1 1 1
Author: LU, Yi