HDU 5826(水题,物理公式推导,积分公式推导直接出结果)

    xiaoxiao2024-07-24  8

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5826

    题目描述很复杂,全是迷惑人的,重要的就用了一个初速度,其他的方向啦,初始位置啦都无所谓。

    有物理公式V^2 - V0^2 = 2ax,  由C =  Vi * Ai' 和 Xi = Vi * Ti;  则V^2 = V0^2 + 2 * A * V *T; 即 V ^2 = V0^2 + 2CT;

    感悟:读题目抓住根本,快读。

    C - physics Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit  Status  Practice  HDU 5826

    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 ac代码:

    #include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; typedef long long LL; #define INF 0x3f3f3f3f #define PI acos(-1) #define MAX_N 10000 #define LOCAL LL v[100005]; int main() { #ifdef LOCAL freopen("b:\\data.in.txt", "r", stdin); #endif int T; scanf("%d", &T); while(T--) { LL n, C;scanf("%I64d%I64d", &n, &C); LL x, d; for(int i = 0; i < n; i++) { scanf("%I64d%I64d%I64d", &v[i], &x, &d); } sort(v, v+n); //速度排序 int q; scanf("%d" ,&q); LL t, k; while(q--) { scanf("%I64d%I64d" ,&t, &k); //加速t秒,第k小的值 printf("%.3lf\n", sqrt(2.0 * C * t + v[k-1] * v[k-1])); } } return 0; }

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