• hdu 5826 physics (物理数学,积分)


    physics

    Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
    Total Submission(s): 817    Accepted Submission(s): 454

    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
     
    Author
    学军中学
     
    Source
     
    题目大意:

    光滑的水平直线上有n个质量相等的小球,已知每个小球的初始位置,初始速度和方向,每个小球的每个时刻的加速度a都满足a*v=c,v是该时刻的速度,c是已知的

    常数,小球之间的碰撞是完全碰撞(不明白就百度),然后q个询问,每次询问第t秒时速度第k小的小球速度是多少?

    题解:

    a = dv/dt = C/v

    -----> vdv = Cdt

    两边同时积分v是从v0-vt,t是从0到t

    -----> [1/2*v^2] (v0---vt) = Ct  (0----t)

    -----> v = sqrt(2*C*t+v0^2);

    #include <iostream>
    #include<cstdio>
    #include<algorithm>
    #include<cstring>
    #include<queue>
    #include<cmath>
    #include<vector>
    using namespace std;
    
    struct node
    {
        double v,x,d;
    }a[100005];
    
    int T,n,q,t,k;
    double c;
    
    bool cmp(node a, node b)
    {
        return a.v<b.v;
    }
    int main()
    {
        scanf("%d",&T);
        for(;T>0;T--)
        {
            scanf("%d%lf",&n,&c);
            for(int i=1;i<=n;i++)
                scanf("%lf%lf%lf",&a[i].v,&a[i].x,&a[i].d);
    
            scanf("%d",&q);
            sort(a+1,a+1+n,cmp);
            for(;q>0;q--)
            {
                scanf("%d%d",&t,&k);
                double v=a[k].v;
                printf("%.3lf
    ",sqrt(v*v+2*c*t));
    
            }
        }
    
        return 0;
    }
  • 相关阅读:
    C# SQL 语句 更新树表的全路径
    递归树 C#
    javascript 在没有找到何时的脚本管理框架前, 使用如下方式在页面上使用脚本
    JS keycode keydown keypress 事件
    C# asp.net 解压缩
    弹出新窗体出现的含有[object]空白页面问题的解决
    include define【11/12/15】
    HDOJ 2191 珍惜现在,感恩生活 【动态规划 多重背包】
    HDOJ 1114 Piggy-Bank 【动态规划 完全背包】
    HDOJ 2602 Bone Collector 【动态规划 01背包】
  • 原文地址:https://www.cnblogs.com/stepping/p/7204479.html
Copyright © 2020-2023  润新知