physics

题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=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.(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

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

Source


2016 Multi-University Training Contest 8


##题意:

在一条无限长水平直轨道上有n个相同的球,给出每个球的初速度、起始位置、方向.
给出若干询问,每次输出 t 秒时第 k 小的速度是多少.
对任意球的任一时刻而言,速度与加速度同方向,且它们的乘积为定值C.


##题解:

由于是变加速度运动,肯定要用积分来解决.
微元法:考虑一段极小的时间间隔:dt. 速度增量为 dv . 则:
![](http://images2015.cnblogs.com/blog/764119/201608/764119-20160811175239356-2092410654.png) 化简为 ![](http://images2015.cnblogs.com/blog/764119/201608/764119-20160811175256668-1857027472.png)
两边同时积分:dv的积分区间为[v0, v], dt的积分区间为[0, t].
那么结果为:![](http://images2015.cnblogs.com/blog/764119/201608/764119-20160811175059152-232557318.png)

关于小球的位置和方向:由于是完全弹性碰撞,碰撞的双方会交换速度,这就等同于忽视碰撞. 所以题目中的初位置和方向都没用.
关于小球速度的大小关系:任意时刻初速度大的都比初速度小的大.
反证:某一时刻,A的速度大于B,则A的加速度就小于B,一段时间后A和B速度相同且拥有相同的加速度. 所以B的速度永远不会超过A.


##代码:
``` cpp
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define LL long long
#define eps 1e-8
#define maxn 101000
#define mod 100000007
#define inf 0x3f3f3f3f
#define mid(a,b) ((a+b)>>1)
#define IN freopen("in.txt","r",stdin);
using namespace std;

double v[maxn];

int main(int argc, char const *argv[])

{

//IN;

int t; cin >> t;
while(t--)
{
double C; int n;
scanf("%d %lf", &n, &C); for(int i=1; i<=n; i++) {
int a,b; scanf("%lf %d %d", &v[i], &a,&b);
}
sort(v+1, v+1+n); int q; scanf("%d", &q);
while(q--) {
int pos; double t; scanf("%lf %d", &t, &pos);
double ans = v[pos]*v[pos] + 2.0*C*t;
ans = sqrt(ans);
printf("%.3f\n", ans);
}
} return 0;

}

HDU 5826 physics (积分推导)的更多相关文章

  1. HDU 5826 physics(物理)

     physics(物理) Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)   D ...

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

    physics Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Sub ...

  3. hdu 5826 physics 物理题

    physics 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5826 Description There are n balls on a smoo ...

  4. HDU 5826 physics

    该问题和xi,di均无关,碰撞只会使得速度反向,大小不会变.因此只要计算速度. #pragma comment(linker, "/STACK:1024000000,1024000000&q ...

  5. hdu 5826 (物理) physics

    题目:这里 题意:光滑的水平直线上有n个质量相等的小球,已知每个小球的初始位置,初始速度和方向,每个小球的每个时刻的加速度a都满足a*v=c,v是该时刻的速度,c是已知的 常数,小球之间的碰撞是完全碰 ...

  6. HDU 5734 Acperience (推导)

    Acperience 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5734 Description Deep neural networks (DN ...

  7. IMU 预积分推导

    给 StereoDSO 加 IMU,想直接用 OKVIS 的代码,但是有点看不懂.知乎上郑帆写的文章<四元数矩阵与 so(3) 左右雅可比>提到 OKVIS 的预积分是使用四元数,而预积分 ...

  8. HDU 5857 Median (推导)

    Median 题目链接: http://acm.split.hdu.edu.cn/showproblem.php?pid=5857 Description There is a sorted sequ ...

  9. hdu 4969 平面几何积分

    http://acm.hdu.edu.cn/showproblem.php?pid=4969 Guizeyanhua要去追一个女孩,女孩在以Guizeyanhua为圆心,半径为R的圆上匀速运动,女孩的 ...

随机推荐

  1. 自定义View(3)关于canas.drawText

    本文以Canvas类的下面这个函数为基础,它用来在画布上绘制文本. public void drawText(String text, float x, float y, Paint paint) 效 ...

  2. Apache httpd + tomcat 简单集群

    集群其实很简单,我们就来说一下httpd+tomcat集群都要注意哪些部分: 首先使用的东西有 apache-tomcat-8.0.32      下载地址: http://tomcat.apache ...

  3. std::ofstream由二进制流写文件的问题

    从MPQ包中读取二进制流出来然后文件写到硬盘. DWORD size = SFileGetSize(hFile); char* buffer = new char[size]; std::ofstre ...

  4. IT玄幻小说

    职业 设计:菜鸟  美工<初级,中级,高级,资深>  设计师<初级,中级,高级,资深>  大神 前端:菜鸟  前端<初级,中级,高级,资深> 架构师<初级,中 ...

  5. Test语言编译器V0.8

    感觉这个挺好耍的,书上的代码有错误,而且功能有限. 一.词法分析 特点: (1)可对中文进行识别:(2)暂不支持负数,可以在读入‘-'时进行简单标记后就能对简单负数进行识别了. #include &l ...

  6. iOS应用的crash日志的分析基础

        Outline如何获得crash日志如何解析crash日志如何分析crash日志     1. iOS策略相关     2. 常见错误标识     3. 代码bug 一.如何获得crash日志 ...

  7. Android 超仿Path时间轴和扇形菜单的效果

    网上看到的  ,仅此记录一下,用到的时候便于查找 效果如下: 源码下载地址 :  http://download.csdn.net/detail/abc13939746593/7251933

  8. .NET之美——C#中的委托和事件(续)

    C#中的委托和事件(续) 引言 如果你看过了 C#中的委托和事件 一文,我想你对委托和事件已经有了一个基本的认识.但那些远不是委托和事件的全部内容,还有很多的地方没有涉及.本文将讨论委托和事件一些更为 ...

  9. java多线程学习笔记——简单

    进程:程序(任务)的执行过程——动态性. 持有资源(共享内存,共享文件)和线程. 线程:线程是系统中最小的执行单元,统一进程中有多个线程,线程共享进程的资源. 线程交互:互斥与同步. 注意:多线程是异 ...

  10. UI控件之 ScrollView垂直滚动控件 和 HorizontalScrollView水平滚动控件的使用

    1. ScrollView 垂直滚动控件的使用 ScrollView控件只是支持垂直滚动,而且在ScrollView中只能包含一个控件,通常是在< ScrollView >标签中定义了一个 ...