HDU.physics【物理+积分】【8月13】

    xiaoxiao2025-01-19  13

    physics

    Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 463    Accepted Submission(s): 293 Problem Description There are n balls on a smooth horizontal straight track. The track can be considered to be a number line. The balls can be considered to be particles with the same mass. At the beginning, ball i is at position Xi. It has an initial velocity of Vi and is moving in direction  Di.(Di1,1) Given a constant C. At any moment, ball its acceleration Ai and velocity Vi have the same direction, and magically satisfy the equation that Ai * Vi = C. As there are multiple balls, they may collide with each other during the moving. We suppose all collisions are perfectly elastic collisions. There are multiple queries. Each query consists of two integers t and k. our task is to find out the k-small velocity of all the balls t seconds after the beginning. * Perfectly elastic collision : A perfectly elastic collision is defined as one in which there is no loss of kinetic energy in the collision.   Input The first line contains an integer T, denoting the number of testcases. For each testcase, the first line contains two integers n <= 10^5 and C <= 10^9. n lines follow. The i-th of them contains three integers Vi, Xi, Di. Vi denotes the initial velocity of ball i. Xi denotes the initial position of ball i. Di denotes the direction ball i moves in.  The next line contains an integer q <= 10^5, denoting the number of queries. q lines follow. Each line contains two integers t <= 10^9 and 1<=k<=n. 1<=Vi<=10^5,1<=Xi<=10^9   Output For each query, print a single line containing the answer with accuracy of 3 decimal digits.   Sample Input 1 3 7 3 3 1 3 10 -1 2 7 1 3 2 3 1 2 3 3   Sample Output 6.083 4.796 7.141 题意:一条直线上有N个球,有加速度Ai,初始速度Vi,方向Di。并且有常数C,每一个球的Ai*Vi=C。问t秒后,速度第k小的球的速度。

    解:

    物理知识:a = dv/dt

    本题中:a = c/v

    带入:vdv = cdt

    两边同时积分:1/2*v^2 = ct+d

    d为常数,令t=0得:d=1/2*v0^2

    带回:1/2*v^2 = ct+1/2*v0^2

    即:v = (2ct+v0^2)^1/2

    #include<cstdio> #include<iostream> #include<cmath> #include<algorithm> using namespace std; double v[100010]; double C, t; int T, N, pi, di, k, q; int main() { scanf("%d", &T); while(T--) { scanf("%d %lf", &N, &C); for(int i = 0;i < N; ++i) scanf("%lf %d %d", &v[i], &pi, &di); sort(v, v+N); scanf("%d", &q); for(int i = 0;i < q; ++i) { scanf("%lf %d", &t, &k); printf("%.3f\n", sqrt(2*C*t+v[k-1]*v[k-1])); } } return 0; }

    转载请注明原文地址: https://ju.6miu.com/read-1295641.html
    最新回复(0)