Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=5826
Test instructions: There are n balls rolling in a straight line, the starting position is XI, the direction is Di (-1 to the left, 1 to the right), the initial speed of VI; The acceleration of this n ball is AI and VI's relationship to AI * vi = c, C is known constant;
n balls may collide and collide for full elastic collisions. and then give you q a question, each time you ask you t seconds after the speed of the small k is how much;
Collision is a fully elastic collision, that is, speed exchange, but the size of the same, so we can ignore the collision, but also can ignore the position of the ball and the direction of movement;
The speed at which K is small after t seconds is, in fact, the number of seconds after the initial K small speed, because V is getting bigger and larger (with a and V in the same direction), so a is getting smaller,
When the starting speed of a ball a < another ball B, then the speed of a is the same as the speed of the ball B, never exceed the speed of ball B;
So what we're going to consider now is that the initial velocity v0 is known as the speed of the T second, where the relationship between acceleration A and velocity v is av=c;
A = DV/DT = c/v
-----> VDV = Cdt
Both sides simultaneously integral V is from V0-v,t is from 0 to T
-----> [V*V/2] (v0---v) = Ct (0----t)
-----> v = sqrt (2*c*t+v0*v0);
#include <iostream>#include<stdio.h>#include<string.h>#include<algorithm>#include<math.h>using namespacestd;#defineINF 0XFFFFFFF#defineN 100050typedefLong LongLL;intV[n];intMain () {intT; scanf ("%d", &T); while(t--) { intN, C, X, D; scanf ("%d%d", &n, &b); for(intI=1; i<=n; i++) scanf (" %d%d%d", &v[i], &x, &d); Sort (v+1, v+n+1); intQ, t, K; scanf ("%d", &q); for(intI=1; i<=q; i++) {scanf ("%d%d", &t, &k); DoubleAns = sqrt (2.0*c*t +1.0*v[k]*V[k]); printf ("%.3f\n", ans); } } return 0;}View Code
Physics---hdu5826 (integral)