Physical experiment
The main topic: there is a vertical pipe with the ground, the pipe mouth and the ground between H, the tube has a lot of elastic ball, from the t=0, the first ball from the mouth to start falling, and then every 1s will have the ball from the current position of the ball to fall, the ball hit the ground to return to the original speed, the ball and the ball , the rate becomes the rate of the other ball at the end of the collision) Ask the final position of all the balls?
This problem is also a problem of elastic collision model, and liner world a bit like, but this question does not require the output of the name of the ball, but you have to find the height of each ball
We can only use this problem to understand a reason is very convenient:
First we look at the situation of a ball:
A ball falls from the height of H and comes back at the original speed of the ground, so his position at the T moment is determined by the following equations:
T=SQRT (2*h/g);
k= (int) (T/T);
hi=h-(t-k*t) * (t-k*t) *G/2; (when K is an even number)
hi=h-(K*T+T-T) * (K*T+T-T) *G/2; (when k is odd)
If there are two balls:
If the first ball does not touch the ground, then the height of the two balls will be determined by hi=h-(t-k*t) * (t-k*t) *G/2 the only one
If the first ball hit the ground, then at a certain moment in the next two balls will collide and exchange speed, can be seen as a brush over, but the problem is not over, if the collision will no longer collide, to determine the height, then how exactly determine it?
We know that because each ball can be regarded as independent, according to test instructions, the height of the 2nd ball should be added to the radius of two balls and divided by 100.0 (the unit is cm see clearly!) ), and then the exchange speed after we switched between 2 and 1, but the state is not changed, we can still think of them as a ball, but also note that the two balls have a radius! (At first I did not think of the radius to kill all want to come out why, simulated a bit to understand), the final answer is from low to high order of the small balls plus 0 and 2r height can be (if there is a must arrange the exchange, or two of the ball will overlap the wrong).
By extending these two cases to multiple balls, we can get a solution.
1#include <iostream>2#include <algorithm>3#include <functional>4#include <math.h>5 6 using namespacestd;7 8 DoubleCalConst Double,Const Double,Const Double);9 Const Doubleg =10.0;Ten Static Doubleh[101]; One A intMainvoid)//a very ingenious physical model problem. - { - intcase_sum, N; the DoubleH, R, T, seg_t; -scanf"%d", &case_sum); - - while(case_sum--) + { -scanf"%D%LF%LF%LF", &n, &h, &r, &T); +seg_t = sqrt (2Hg); A at for(inti =0; i < N; i++) -H[i] = cal (seg_t, T-i, H);//1s reduction per interval -Sort (H, H +N); - for(inti =0; i < N; i++) -printf"%.2f", H[i] +2* R*i/100.0); -printf"\ n"); in } - returnexit_success; to } + - DoubleCalConst DoubleTConst DoubleTConst DoubleH) the { * if(T <0) $ returnH//It's the equivalent of not even starting to fall .Panax Notoginseng intK = (int) (t/t);//See whether it is the ascending or descending stage. - ifK2==0)//Descent Phase the returnh-g* (t-k*t) * (t-k*t)/2; + Else A returnh-g* (k*t + t-t) * (k*t + t-t)/2; the +}
Greedy:physics Experiment (Elastic Collision model) (POJ 3848)