physics HDU - 5826(数学)

本文介绍了一种在平直轨道上多个质量相同的粒子发生弹性碰撞的物理模型,粒子的初始位置、速度及方向已知,粒子间的碰撞为完全弹性碰撞。文章详细探讨了如何根据这些条件来计算指定时间内所有粒子速度的第k小值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 accelerationAi and velocity Vi have the same direction, and magically satisfy the equation that AiVi=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 integersn<=105 andC<=109.
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<=105, denoting the number of queries.
q lines follow. Each line contains two integers t<=109 and 1<=k<=n.
1<=Vi<=105,1<=Xi<=109
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个球,各自有一定的初速度,和方向(也就是说球与球之间会发生碰撞,为弹性碰撞),并且每个球的速度和加速度乘积为一个常数,那天我在的话就把这题给a了,唯一的难点可能就是积分吧,关于碰撞,只要把他当称两球相互穿过就可以了,如果只根据动量守恒定律那么速度是可以抵消的,但是在这里还得遵循能量守恒定律,没有能量损失,并且在质量相等的情况下,两者速度交换即可,因为球都是一样的,就当作相互穿过就好了
现在看积分:

viA=C
dvdt=A=Cv

移向:
vdv=Cdt
两边同时积分有:
vxvivdv=Ctx0dt

得:
v2xv2i2=Ctx

所以:
vx=v2i+2Ctx

至于询问,只要从小到大排序即可,因为这个速度函数是递增的,经过相同时间,他们的大小关系不会改变
代码:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<cmath>
#define N 100005
#define mod 530600414
using namespace std;
int a[100005];
int n,c;
int main()
{
    int t;
    int m;
    int x,y;
    int time,k;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&c);
        for(int i=1;i<=n;i++)
            scanf("%d%d%d",a+i,&x,&y);
        sort(a+1,a+1+n);
        scanf("%d",&m);

        while(m--)
        {
            scanf("%d%d",&time,&k);
            printf("%.3lf\n",sqrt((double)a[k]*a[k]+2*c*(double)time));
        }
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值