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 <= 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<=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

Hint

题意

给你n个球,以及球的位置,球初始方向,球保证都在x轴上。

而且V[i]*A[i] = C

现在有Q次询问,问你在第t秒,第k大的速度是多少。

题解:

弹性碰撞,那么其实就是交换速度,那么就和位置无关了。

第k大,其实就是开始速度第k大的球。

速度怎么求呢? V[i]*A[i] = C ,那么 Cdt = V[i]dV,然后积分 2k+2Ct = V[i]^2,把初速度带进去,把k解出来就好了。

(其实功率是守恒的,用这个做也很简单

代码

#include <bits/stdc++.h>

using namespace std;

int V[100010];
int n,c,t,k,q,T; double solve(int v,int t)
{
return (sqrt(1.0*v*v+2.0*t*c));
} int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&c);
for(int i=1;i<=n;i++)
{
int v,x,d;
scanf("%d%d%d",&v,&x,&d);
V[i]=v;
}
sort(V+1,V+1+n);
scanf("%d",&q);
while(q--)
{
scanf("%d%d",&t,&k);
printf("%.3f\n",solve(V[k],t));
}
}
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 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5826 Description There are n balls on a smoo ...

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

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

  4. HDU 5826 physics

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

  5. hdu 5761 Rower Bo 物理题

    Rower Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5761 Description There is a river on the Ca ...

  6. hdu 5066 小球碰撞(物理题)

    http://acm.hdu.edu.cn/showproblem.php?pid=5066 中学物理题 #include <cstdio> #include <cstdlib> ...

  7. [物理题+枚举] hdu 4445 Crazy Tank

    题意: 给你N个炮弹的发射速度,以及炮台高度H和L1,R1,L2,R2. 问任选发射角度.最多能有几个炮弹在不打入L2~R2的情况下打入L1~R1 注意:区间有可能重叠. 思路: 物理题,发现单纯的依 ...

  8. HDU 1155 Bungee Jumping(物理题,动能公式,弹性势能公式,重力势能公式)

    传送门: Bungee Jumping Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  9. Codeforces Round #114 (Div. 1) A. Wizards and Trolleybuses 物理题

    A. Wizards and Trolleybuses Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...

随机推荐

  1. 【Swift】iOS 9 Core Spotlight

    前言 感觉 Spotlight 这个功能还是蛮有用的,能提升用户活跃,增加应用内容曝光几率. 声明 欢迎转载,但请保留文章原始出处:) 博客园:http://www.cnblogs.com 农民伯伯: ...

  2. Hadoop 2.6.0+ZooKeeper+Hive HA高可用集群安装

    http://blog.csdn.net/totxian/article/details/45248399

  3. WebApi身份认证解决方案:Basic基础认证

    前言:最近,讨论到数据库安全的问题,于是就引出了WebApi服务没有加任何验证的问题.也就是说,任何人只要知道了接口的url,都能够模拟http请求去访问我们的服务接口,从而去增删改查数据库,这后果想 ...

  4. Scala 深入浅出实战经典 第75讲:模式匹配下的For循环

    王家林亲授<DT大数据梦工厂>大数据实战视频 Scala 深入浅出实战经典(1-87讲)完整视频.PPT.代码下载: 百度云盘:http://pan.baidu.com/s/1c0noOt ...

  5. 制作第一个UI字体

    为什么要制作UI字体 一般来说,会有系统默认字体共我们使用,但是出于以下两个原因我们经常会需要制作独特的字体. 1.系统字体的风格和美观程度等无法满足需求. 一般来说,系统字体都比较死板.生硬,风格单 ...

  6. 如何给Qlabel添加clicked属性(覆盖mousePressEvent,处理QMouseEvent消息,反正是软绘制,想怎么样就怎么样)

    clickedLabel.h #ifndef CLICKLABEL_H #define CLICKLABEL_H #include <QLabel> #include <QMouse ...

  7. UVAlive3713 Astronauts(2-SAT)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18511 [思路] 2-SAT. 设分得A或B类任务为1 C类任务为 ...

  8. C++实现二叉树的基本操作

    #include <iostream> #include <stack> #include <queue> using std::cin; using std::c ...

  9. IOS 学习笔记(6) 控件 文本域(UITextField)的使用方法

    UITextField控件的诸多特性都和UITextView相似,比如成为输入文本焦点时键盘自动显示,支持长按弹出动作选项,能够接收输入事件(开始输入,修改内容,结束输入和点击回车等). 1.特有的特 ...

  10. PAT-B 1015. 德才论(同PAT 1062. Talent and Virtue)

    1. 在排序的过程中,注意边界的处理(小于.小于等于) 2. 对于B-level,这题是比較麻烦一些了. 源代码: #include <cstdio> #include <vecto ...