2016多校训练Contest8: 1006 physics hdu5826
2016-08-12 16:06
246 查看
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
Sample Output
数轴上有若干小球,他们互相碰撞为弹性碰撞。给定一个常数C,满足加速度a*速度v=C, q个询问,问t时刻第k小速度的球速度是多少
首先。因为是弹性碰撞。所以我们可以直接当成穿过,因此题目中的位置和方向是无用信息
然后考虑怎么算速度。一种方法是微积分。
另外一种方法是观察这个式子v*a=C,考虑功率式v*f=P,因此v*f/m=C=P/m,因为m为定值,因此功率不变。所以所做的功全部转化为动能
上面两种方法均可以算出t时刻速度为Vt=sqrt(2*c*t+v0*v0)
可以发现这个速度的相对大小不变,因此一开始排序,询问直接求出即可
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
数轴上有若干小球,他们互相碰撞为弹性碰撞。给定一个常数C,满足加速度a*速度v=C, q个询问,问t时刻第k小速度的球速度是多少
首先。因为是弹性碰撞。所以我们可以直接当成穿过,因此题目中的位置和方向是无用信息
然后考虑怎么算速度。一种方法是微积分。
另外一种方法是观察这个式子v*a=C,考虑功率式v*f=P,因此v*f/m=C=P/m,因为m为定值,因此功率不变。所以所做的功全部转化为动能
上面两种方法均可以算出t时刻速度为Vt=sqrt(2*c*t+v0*v0)
可以发现这个速度的相对大小不变,因此一开始排序,询问直接求出即可
#include<map> #include<cmath> #include<queue> #include<vector> #include<cstdio> #include<string> #include<cstring> #include<iostream> #include<algorithm> using namespace std; double a[200001]; inline double cal(double v0,double c,double t) { return sqrt(double(2)*c*t+double(v0)*double(v0)); } int main() { int T; scanf("%d",&T); while(T>0) { T--; int n,c; scanf("%d%d",&n,&c); int i,x,t; for(i=1;i<=n;i++) { scanf("%lf",&a[i]); scanf("%d%d",&x,&x); } int m; scanf("%d",&m); sort(a+1,a+1+n); for(i=1;i<=m;i++) { scanf("%d%d",&t,&x); printf("%.3lf\n",cal(a[x],c,t)); } } return 0; }
相关文章推荐
- 2016多校训练Contest6: 1006 Stabilization hdu5798
- 2016多校训练Contest8: 1001 Ball hdu5821
- 2017 多校训练 1006 Function
- PAT训练(乙级)—— 1006. 换个格式输出整数 (15)
- 2016多校训练Contest4: 1011 Where Amazing Happens hdu5774
- 2016多校联合训练7&&HDU5816
- 2016多校训练Contest4: 1001 Another Meaning hdu5763
- 2016多校训练Contest7: 1004 Distance hdu5812
- 2016多校训练Contest10: 1004 Death Sequence hdu5860
- 2016多校训练Contest5: 1007 K-wolf Number hdu5787
- 2016多校训练Contest8: 1011 Rikka with Parenthesis II hdu5831
- 2016多校训练Contest5: 1005 Interesting hdu5785
- hdu 5739 Fantasia (2016多校第二场1006)
- 2016多校训练Contest8: 1003 color II hdu5823
- 2016 Multi-University Training Contest 10(2016多校训练第十场)1011
- 2016多校第一场 1006 hdu 5728 PowMod
- 2017多校训练Contest2: 1006 Funny Function hdu6050
- 2016多校训练Contest7: 1010 Joint Stacks hdu5818
- 2016多校训练Contest8: 1008 Rikka with Sequence hdu5828
- 2016多校训练一 PowMod,hdu5728(欧拉函数+指数循环节)