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.(Di∈?1,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

2016 Multi-University Training Contest 8

题目大意:

光滑的水平直线上有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\n",sqrt(v*v+2*c*t));

        }
    }

    return 0;
}
时间: 2024-08-09 12:01:45

hdu 5826 physics (物理数学,积分)的相关文章

HDU 5826 physics(物理)

HDU 5826 physics(物理) Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)   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 con

hdu 5826 physics

水题: 题意:给你n个球,在一维方向上,每个球给三个量,分别为初速度v,初始坐标x,方向(1||-1),每个球会运动,加速度为a,满足a*v=c,c已知,可能会完全碰撞,问第t秒第k小的速度是多少: 想法:第一眼看到a*v=c,立即想到了高中物理的恒定功率,小车的加速阶段的运动模型,设m=1,则a*m*v=c=p:再用动量定理,p*t=1/2*m*v*v-1/2*m*v0*v0,即可得出: 代码: #include <bits/stdc++.h> using namespace std; co

hdu 5826 (物理) physics

题目:这里 题意:光滑的水平直线上有n个质量相等的小球,已知每个小球的初始位置,初始速度和方向,每个小球的每个时刻的加速度a都满足a*v=c,v是该时刻的速度,c是已知的 常数,小球之间的碰撞是完全碰撞(不明白就百度),然后q个询问,每次询问第t秒时速度第k小的小球速度是多少? 完全碰撞即碰撞后速度交换,速度还是那两个速度,只是不是原来那个球了而已,但这并不时需要考虑的,因为只需要关心速度,所以初始方向以及初始位置什么的都不需要在意, 因为加速度a=c/v,加速度每时每刻都在变,速度每时每刻也在

HDU 1714 RedField 一重积分

题目链接:点击打开链接 给定椭圆的标准方程,椭圆外一点(x,y) 且 x>=a , abs(y)>=b 求阴影面积 先求出直线与椭圆的交点(x1, y1), 然后积分即可. #include <stdio.h> #include <iostream> #include <algorithm> #include <sstream> #include <stdlib.h> #include <iomanip> #include

HDU 1724 Ellipse [辛普森积分]

Ellipse Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1868    Accepted Submission(s): 792 Problem Description Math is important!! Many students failed in 2+2’s mathematical test, so let's AC t

hdu 4969 Just a Joke(积分)

题目链接:hdu 4969 Just a Joke 题目大意:Guizeyanhua要去追一个女孩,女孩在以Guizeyanhua为圆心,半径为R的圆上匀速运动,女孩的速度为v1,Guizeyanhua的速度为v2,半径为R,Guizeyanhua腿疼只能跑距离D.现在Guizeyanhua要去追女孩,前提条件是女孩,Guizeyanhua,圆心必须保持共线. 解题思路:因为有三点要共线的条件,所以Guizeyanhua和女孩的线速度必须相同,所以有v1R=vxr(vx为Guizeyanhua在

HDU 4969 Just a Joke(积分)

HDU 4969 Just a Joke 题目链接 推公式,r′=dr/dt=vy=v22?v12r2/R2????????????√,可得积分公式为 ∫R0y=1/v22?v12x2/R2?????????????√,利用三角换元去化简即可 代码: #include <cstdio> #include <cstring> #include <cmath> typedef long long ll; int t; double v1, v2, r, d; int mai

HDU 1724 Ellipse 【自适应Simpson积分】

Ellipse Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1977    Accepted Submission(s): 832 Problem Description Math is important!! Many students failed in 2+2's mathematical test, so let's AC t

Hdu 4498 Function Curve(Simpson积分)

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4498 思路:分段积分.求出每个函数与y=100和每两个函数图像的交点,排序后枚举每段取最小值,分段积分. #include<cstdio> #include<vector> #include<cstring> #include<iostream> #include<algorithm> #define debu using namespace std