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. Codeforces Round #481 (Div. 3) D. Almost Arithmetic Progression

    http://codeforces.com/contest/978/problem/D 题目大意: 给你一个长度为n的b(i)数组,你有如下操作: 对数组中的某个元素+1,+0,-1.并且这个元素只能 ...

  2. Flex 编写 loading 组件

    Flex 界面初始化有时那个标准的进度条无法显示,界面长时间会处理空白的状态!我们来自定义一个进度条, 这个进度条加载在 Application 应用程序界面的 <s:Application 标 ...

  3. iOS 解决汉字联想输入,导致字数限制失效的问题

    字数限制的问题点在于汉语可以无限汉语联想词汇,导致字数限制对于汉字输入就失去的作用.我们的做法是监听键盘联想出来的汉子,将其统计: 1 在viewDidLoad里面监听文本变化的通知 - (void) ...

  4. 用MFC(C++)实现拼音搜索

    2015年4月1日更新: 我在github开源了Objective-C版的拼音搜索项目,感兴趣的可以去看看: OC版拼音搜索 最近项目需要实现按照拼音搜索资源.在网上找了一下,这方面的东西太少了. J ...

  5. HDU 1869 六度分离 最短路

    解题报告: 1967年,美国著名的社会学家斯坦利·米尔格兰姆提出了一个名为“小世界现象(small world phenomenon)”的著名假说,大意是说,任何2个素不相识的人中间最多只隔着6个人, ...

  6. xml json

    简单概括的话就是,xml本身是一种格式规范,是一种包含了数据以及数据说明的文本格式规范. 比如,我们要给对方传输一段数据,数据内容是“too young,too simple,sometimes na ...

  7. 运算符,比如+, -, >, <, 以及下标引用[start:end]等等,从根本上都是定义在类内部的方法。

    python解释器在碰到+号运算符时,会调用加号前面的对象的__add__方法 class a: def __add__(self,b): print "ghh" aa=a() a ...

  8. [LeetCode] Candy (分糖果),时间复杂度O(n),空间复杂度为O(1),且只需遍历一次的实现

    [LeetCode] Candy (分糖果),时间复杂度O(n),空间复杂度为O(1),且只需遍历一次的实现 原题: There are N children standing in a line. ...

  9. MongoDB存储基础教程

    一.MongoDB简介 1. mangodb是一种基于分布式.文件存储的非关系型数据库 2. C++写的,性能高 3. 为web应用提供可扩展的高性能数据存储解决方案 4. 所支持的格式是json格式 ...

  10. Extjs Window用法详解 2 打印具体应用

    Extjs 中的按钮元素 { xtype: 'buttongroup', title: '打印', items: [ me.tsbDel = Ext.create('Ext.button.Button ...