(2016 Multi) physics hdu 5826

来源:互联网 发布:怎么面试美工 编辑:程序博客网 时间:2024/06/05 06:50

物理题。。。
题意:给出各个球的初始速度,位置坐标,运动方向,以及加速度*速度是不变的常量。求当t时的第k小的速度的大小。
题解:小球在一条直线运动,且碰撞是完全弹性碰撞,所以其实答案(t时候的速度)跟位置和运动方向无关么,那么我们完全可以认为小球都在作直线运动。加速度 * 速度是不变的常量,这就需要物理知识了么,根据 a = dv / dt , a = C / v . 推出: 积分(0->t)c * dt = 积分(v0 -> v)v * dv. 推出 :v(答案)= sqrt(2 * C * t + v0 * v0 )。

#include<iostream>#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>#include<queue>#include<stack>using namespace std;#define INF 0x3f3f3f3ftypedef long long LL;const double PI = acos(-1.0);const int mod = 1e9 + 7;const int N = 100100;int n;LL m;LL v[N];int main(){    int tcase;    scanf("%d",&tcase);    while(tcase--)    {        scanf("%d%lld",&n,&m);        for(int i = 0; i < n; i++)        {            int die,dis;            LL v0;            scanf("%lld%d%d",&v0,&dis,&die);            v[i] = v0*v0;        }        sort(v,v+n);        int q;        scanf("%d",&q);        while(q--)        {            int k;            LL t;            scanf("%lld%d",&t,&k);            LL ans = 2*t*m;            ans = ans + v[k-1];            //printf("%lld %lld\n",v[k-1],ans);            double da = sqrt((double)ans);            printf("%.3lf\n",da);        }    }}
0 0