http://poj.org/problem?id=3684
Simon is doing a physics experiment with N identical balls with the same radius of R centimeters. Before the experiment, all N balls are fastened within a vertical tube one by one and the lowest point of the lowest ball is Hmeters above the ground. At beginning of the experiment, (at second 0), the first ball is released and falls down due to the gravity. After that, the balls are released one by one in every second until all balls have been released. When a ball hits the ground, it will bounce back with the same speed as it hits the ground. When two balls hit each other, they with exchange their velocities (both speed and direction).
Simon wants to know where are the N balls after T seconds. Can you help him?
In this problem, you can assume that the gravity is constant: g = 10 m/s2.
http://d.hatena.ne.jp/kanetai/20111018/1318943658
Read full article from poj 3684 - hyx1 - 博客园
Simon is doing a physics experiment with N identical balls with the same radius of R centimeters. Before the experiment, all N balls are fastened within a vertical tube one by one and the lowest point of the lowest ball is Hmeters above the ground. At beginning of the experiment, (at second 0), the first ball is released and falls down due to the gravity. After that, the balls are released one by one in every second until all balls have been released. When a ball hits the ground, it will bounce back with the same speed as it hits the ground. When two balls hit each other, they with exchange their velocities (both speed and direction).
Simon wants to know where are the N balls after T seconds. Can you help him?
In this problem, you can assume that the gravity is constant: g = 10 m/s2.
http://d.hatena.ne.jp/kanetai/20111018/1318943658
- Reference
const int MAX = 105; const double g = 10.0; int N,H,R,T; double y[MAX]; double cal(int T) { if(T < 0) return H; double t = sqrt(2 * H / g); int k = (int) T / t; if(k % 2 == 0) { double d = T - k * t; return H - g * d * d / 2; } else { double d = k * t + t - T; return H - g * d * d / 2; } } void solve() { for(int i = 0; i < N; ++i) { y[i] = cal(T - i); } sort(y ,y + N); for(int i = 0; i < N; ++i) { printf("%.2f%c",y[i] + 2 * R * i / 100.0,i + 1 == N ? '\n' : ' '); } } int main() { int C; //freopen("sw.in","r",stdin); scanf("%d",&C); while(C--) { scanf("%d%d%d%d",&N,&H,&R,&T); solve(); } // cout << "Hello world!" << endl; return 0; }
Read full article from poj 3684 - hyx1 - 博客园