Three equal circles at rest; particle 1 moves along a given vector and transfers motion on contact. Decide which of five collision chains occurs.
Medium6GeometrySimulationMathImplementationNo attempts yetTime limit1sMemory limit512 MBBuilding a particle collider is hard, and running one experiment on it costs a lot. Checking an idea in simulation first is cheaper than testing it on real hardware. Write a simple simulator for the setup below.
The system holds exactly three particles. All of them stay on an infinite plane, so each one is a circle. The position of particle i is given only by the coordinates xi and yi of its center (1≤i≤3). The three particles share the same radius r, and all of them are at rest at the start.
Once the experiment starts, particle 1 moves in the direction of the vector (xv,yv). When particle i touches particle j, particle j starts moving in the direction perpendicular to the common tangent at the contact point, which points away from particle i. At that instant particle i disappears and turns into radiation. A moving particle that touches no other particle keeps moving forever.
The simulator has to tell these five outcomes apart.
The input has four lines. Each of the first three lines holds two integers xi and yi (∣xi∣,∣yi∣≤1000), describing particle 1, particle 2, and particle 3 in that order. The fourth line holds three integers xv, yv, and r (∣xv∣,∣yv∣≤1000, 0<r≤50). The vector (xv,yv) is not the zero vector.
No two particles touch or overlap at the start, and the distance between the centers of particle 2 and particle 3 is greater than 4r.
Print the number of the outcome listed above as a single integer from 1 to 5.
Compute carefully. The outcome is guaranteed to stay the same if the initial vector (xv,yv) is rotated by one degree in either direction.