luogu#P4682. [ZJOI2007] 粒子运动

[ZJOI2007] 粒子运动

Problem Description

Dr. A-Q is observing the motion of particles in a circular container. Let us set up a 2D Cartesian coordinate system. The center of the circular container is at (x0,y0)(x_0, y_0), with radius RR. There are several particles in the container. Suppose the position of the ii-th particle at time 00 is (xi,yi)(x_i, y_i), and its velocity is (vxi,vyi)(v_{x_i}, v_{y_i}) (note: this is a velocity vector; if no collision happens, then at time tt its position should be (xi+tvxi,yi+tvyi)(x_i + t * v_{x_i}, y_i + t * v_{y_i})). Assume that the motions of all particles do not affect each other. If a particle hits the container wall at some moment, a perfectly elastic collision occurs: the velocity direction is reflected like a mirror with respect to the tangent line at the collision point, and the speed remains unchanged (as shown in the figure). The collision is considered to be instantaneous.

particle

Although collisions do not affect a particle’s speed, the particle will take some damage. Therefore, if a particle has collided with the container wall kk times, then it will vanish at its kk-th collision.

For research purposes, Dr. A-Q wants to know, from time 00 until all particles have vanished, what the minimum distance ever achieved between any two particles is. Can you help him?

Input Format

The first line of the input file particle.in contains three real numbers x0,y0,Rx_0, y_0, R, which are the center coordinates and radius of the circular container. The second line contains two positive integers N,kN, k, representing the total number of particles and the number of collisions at which a particle vanishes. The next NN lines each contain four real numbers xi,yi,vxi,vyix_i, y_i, v_{x_i}, v_{y_i}, guaranteeing that (xi,yi)(x_i, y_i) are all inside the circle and (vxi,vyi)(v_{x_i}, v_{y_i}) is non-zero.

Output Format

The output file particle.out contains only one real number: the minimum distance ever achieved between any two particles over the whole history, accurate to three digits after the decimal point.

0 0 10
2 10
0 -5 0 1
5 0 1 0
7.071

Hint

For all testdata, 2N1002 \leq N \leq 100. 1k1001 \leq k \leq 100.

Please pay attention to floating-point precision issues.

Translated by ChatGPT 5