2016多校训练Contest8: 1006 physics hdu5826
来源:互联网 发布:优美的句子 知乎 编辑:程序博客网 时间:2024/04/28 02:24
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
数轴上有若干小球,他们互相碰撞为弹性碰撞。给定一个常数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;}
0 0
- 2016多校训练Contest8: 1006 physics hdu5826
- 2016多校训练Contest8: 1001 Ball hdu5821
- 2016多校训练Contest8: 1008 Rikka with Sequence hdu5828
- 2016多校训练Contest8: 1003 color II hdu5823
- 2016多校训练Contest8: 1011 Rikka with Parenthesis II hdu5831
- 2016多校联赛 hdu5826 physics 数学题
- [HDU5826] physics [2016 Multi-University Training Contest 8(2016多校联合训练8) 1006]
- HDU5826 physics
- HDU5826 physics
- 2016多校训练总结
- 【HDU5826】physics(物理题 + 数学题)
- 2016多校训练Contest4: 1006 Substring hdu5769
- 2016多校训练Contest6: 1006 Stabilization hdu5798
- 2016多校训练Contest10: 1006 Counting Intersections hdu5862
- 2016湖南多校训练第一场
- 2016多校训练1 hdu5733 tetrahedron
- 多校训练
- 【1】【物理/积分】HDU5826 physics
- PowerDesigner 链接Oracle,并生成相应的数据结构
- uploadify上传文件在360浏览器急速模式下失败
- mongodb的安装
- jadx:更好的Android反编译工具
- 每个程序员都应该收藏的算法复杂度速查表
- 2016多校训练Contest8: 1006 physics hdu5826
- 大理石刻字
- 认识Uboot(一)
- 内存限制下查找数组的重复数
- Java实现邮件发送【带附件】
- JPA常用注解
- 关于eclipse运行和调试结果不同的问题
- 【数据结构和算法】用java简单的实现单链表的基本操作
- 关于既使用maven编译,又使用lib下的Jar包的问题