HDU 5826-physics
来源:互联网 发布:为什么要探索宇宙 知乎 编辑:程序博客网 时间:2024/05/20 06:05
physics
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 866 Accepted Submission(s): 477
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 directionDi.(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.
At the beginning, ball i is at position Xi. It has an initial velocity of Vi and is moving in direction
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
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
13 73 3 13 10 -12 7 132 31 23 3
Sample Output
6.0834.7967.141
Author
学军中学
Source
2016 Multi-University Training Contest 8
Recommend
wange2014
题意:给你n个小球,这些小球有起始的位置和方向,然后还有一个常数C,小球的瞬时速度和加速度满足av=C,有q次查询,问你在t秒后速度第k小的小球的速度。小球碰撞的时候是完全弹性碰撞。
解题思路:两个小球完全弹性碰撞之后,可以想象为两个球穿过去了。根据题意可以列出方程a=dv/dt=C/v,得v*v-v0*v0=2Ct,v0为小球初始速度,v为t秒后小球的速度,这样就可以解出来了,要求第k个,因为小球的速度是不断增加,那么我们将小球按照初始速度排序,那么最后直接求v[k]在t秒后的速度即可
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <map>#include <cmath>#include <set>#include <stack>#include <queue>#include <vector>#include <bitset>#include <functional>using namespace std;#define LL long longconst int INF = 0x3f3f3f3f;int n,q,x,d,y;double v[100009],c;int main(){ int t; scanf("%d",&t); while(t--) { scanf("%d%lf",&n,&c); for(int i=1;i<=n;i++) scanf("%lf%d%d",&v[i],&x,&d); sort(v+1,v+1+n); scanf("%d",&q); while(q--) { scanf("%d%d",&x,&y); double vv=v[y]; printf("%.3lf\n",1.0*sqrt(2*c*x+vv*vv)); } } return 0;}
阅读全文
0 0
- hdu 5826 physics
- HDU 5826 physics
- hdu 5826 physics
- HDU 5826-physics
- hdu 5826 physics (物理+积分)
- HDU-5826-physics-数学推导
- HDU 5826 physics(物理)
- HDU 5826 physics 【弹性碰撞】
- 物理题(physics,HDU 5826)
- physics HDU
- HDU 5826 physics (数学推导)(规律)
- hdu 5826 physics (物理数学)
- (2016 Multi) physics hdu 5826
- hdu 5826 physics 2016 Multi-University 8
- HDU 5826 physics(公式推导+sort)
- hdu 5826 physics 物理+数学微分方程
- HDU-5826 physics(物理定理+微分方程)
- [HDU 5826] physics (简单物理题+简单积分)
- Codeforces Round #433 (Div. 2) C. Planning(贪心)
- EL表达式
- iOS设置圆角的三种方式
- python request上传文件
- Codeforces Round #433(Div. 1,based on Olympiad of Metropolises)A Planning B Jury Meeting C Boredom
- HDU 5826-physics
- 浅谈Javascript
- explicit作用,拷贝构造函数,隐式类型
- JDK8流式处理数据
- 15. Yii 2.0 页面缓存
- spring事务管理UnexpectedRollbackException
- 以客户为中心进行数据挖掘
- 为什么Nginx的性能要比Apache高很多?
- HDU