PKU Acm3684--physics Experiment

Source: Internet
Author: User

This question, the title means that there are n balls from the height of the place of H, every second to drop a ball, ball and ball and the ball and the floor are directly elastic collision, the T-seconds after the position of each ball, that is, the height.

This problem, similar to ants, that is, the ball and the ball collision can be used as a non-conversion direction, continue to follow the original direction. That is, when r = 0, ignore the radius, calculate the position of each ball, each ball and the floor after the collision, will rise to the original height. The first time to calculate the drop requires t = sqrt (2 * h/g), each ball total time t, a total of complete return to k = t/t times.

K is odd and the final height is h-g * (k * t + t-t) ^ 2.

K is even and the final height is h-g * (t-k * T) ^ 2.

Figure out each ball, after sorting, is the final position of each ball, but the ball's R is 0.

Because R is greater than or equal to 1. So, finally add 2 * i * r/100.0 OK, I is the first ball, because R is the unit of centimeters, so divided by 100.0.

The following is the code for the AC:

#include <iostream> #include <cmath> #include <cstdio> #include <algorithm>using namespace std; int N, H, R, t;const double g = 10.0;double y[105];d ouble fun (int t) {if (T < 0) return h;double d;double temp = sqrt (2 * h/g); int k = int (t/temp), if (k% 2 = = 0) {d = t-temp * k;} else{d = k * temp + temp-t;} return h-g * d * D/2;} void Solve () {for (int i = 0; i < N; i++) {Y[i] = fun (t-i);} Sort (y, y + N); for (int j = 0; J < N; J + +) {j = = N-1 printf ("%.2lf\n", Y[j] + 2 * R * j/100.0): printf ("%.2lf", y [j] + 2 * R * j/100.0);}} int main () {int c;scanf ("%d", &c), while (c--) {scanf ("%d%d%d%d", &n, &h, &r, &t); solve ();} return 0;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

PKU Acm3684--physics Experiment

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.