Poj:3684-physics Experiment (Elastic collision) __ Elastic collision

Source: Internet
Author: User
Physics Experiment

Time limit:1000ms Memory limit:65536k
Total submissions:3392 accepted:1177 Special Judge Description

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 H meters above the ground. At beginning of the experiment, (at second 0), the the-ball is released and falls down due to the gravity. After this, the balls are released one by one on every second until all balls have been. When a ball hits the ground, it'll bounce back with the same speed as it hits the ground. When two balls hit all other, they with exchange their velocities (both speed and direction).

Simon wants to know where are of the N balls after T seconds. Can you help him?

In this problem, your can assume that gravity is constant:g = m/s2. Input

The "a" of the input contains one integer C (c≤20) indicating the number of test cases. Each of the following lines contains four integers N, H, R, T.
1≤n≤100.
1≤h≤10000
1≤r≤100
1≤t≤10000 Output

For each test case, your program should output N real numbers indicating the height in meters to the lowest point of each Ball separated by a single. Each number should is rounded to 2 digit on the decimal point. Sample Input

2
1 10 10 100
2 Sample Output

4.95
4.95 10.20

Problem-solving experience: There are many small balls from the height of H plane to the ground to do freefall, every 1 seconds drop a small ball, if the ball in the air collision, then two ball direct exchange speed (including size and direction). A look at this question the first reaction is the ant walk line problem, this problem and the Ant walk line has many similarities, two small ball collision can be seen as two balls directly from the other side of the body through, because speed Exchange can be seen as speed unchanged. But there is a problem is the ball has a radius, two ball collision place is not the center, but the top of the ball, above the ball below, in fact, more than a 2r, there is a small ball more than one 2r, so in the final calculation results of the time plus a 2rxi on the line. A small pit point is the R unit is cm, the height is m. The rest is the examination of the free fall knowledge of high school.

 #include <algorithm> #include <stdio.h> #include <math.h> using namespace
Std
const int MAXN = 110;

Const double g = 10.0;
Double H[MAXN];

int N, h, R, T, C;

void Init () {scanf ("%d%d%d%d", &n, &h, &r, &t);
    Double cal {if (Times <= 0) return h;
    Double T = sqrt (2.0 * (double) h/10.0);
    int k = (int) (TIMES/T); if (K & 1)//Pay attention to the calculation formula of free fall return (double) h-g * (double) k * t + t-times) * (double) k * t + t-times)
    2.0;
Return (Double) h-g * (Times-(double) k * t) * (Times-(double) k * t)/2.0;
    int main () {scanf ("%d", &c);
        while (c--) {init ();
        for (int i = 0; i < n; i++) H[i] = cal (t-i);
        Sort (h,h+n); for (int i = 0; i < n; i++) printf ("%.2f%c", H[i] + 2.0 * R * i/100.0, i = = n-1?
    ' \ n ': ');
return 0; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.