HDU 5826 physics(积分 找规律)——2016 Multi-University Training Contest 8
来源:互联网 发布:什么租房软件最好 编辑:程序博客网 时间:2024/05/21 12:47
传送门
physics
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 95 Accepted Submission(s): 66
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
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
题目大意:
在一条无限长水平直轨道上有
始位置
对任意球的任一时刻而言,速度与加速度同方向,且它们的乘积为定值
解题思路:
直接根据公式:
那么将
然后到了这步就可以对两边进行积分得左边的积分上限是
所以得到了公式就是:
因为让我们求的是第
/**2016 - 08 - 11 晚上Author: ITAKMotto:今日的我要超越昨日的我,明日的我要胜过今日的我,以创作出更好的代码为目标,不断地超越自己。**/#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <vector>#include <queue>#include <algorithm>#include <set>using namespace std;typedef long long LL;typedef unsigned long long ULL;const int INF = 1e9+5;const int MAXN = 1e5+5;const LL MOD = 1e9+7;const double e = 2.718281828459;const double eps = 1e-7;const double PI = acos(-1);using namespace std;int x[MAXN], d[MAXN];double v[MAXN];inline bool cmp(int a, int b){ return a > b;}int main(){ int T, n; double C; scanf("%d",&T); while(T--) { scanf("%d%lf",&n,&C); for(int i=1; i<=n; i++) scanf("%lf%d%d",&v[i],&x[i],&d[i]); sort(v+1, v+n+1); int Q; scanf("%d",&Q); while(Q--) { int k; double t; scanf("%lf%d",&t, &k); printf("%.3lf\n",sqrt(v[k]*v[k]+2*t*C)); } } return 0;}
0 0
- HDU 5826 physics(积分 找规律)——2016 Multi-University Training Contest 8
- hdu 5826 physics(2016 Multi-University Training Contest 8——积分求解)
- HDU 5399 Too Simple(数学 + 找规律)——2015 Multi-University Training Contest 9
- HDU 6038 Function(找规律)——2017 Multi-University Training Contest
- HDU 6048 Puzzle(找规律)——2017 Multi-University Training Contest
- HDU 5754 Life Winner Bo(找规律 + 威佐夫博弈)--2016 Multi-University Training Contest 3
- HDU 5351 MZL's Border(大数 + 找规律)——2015 Multi-University Training Contest 5
- hdu 6038 找规律 置换 2017 Multi-University Training Contest
- 2016 Multi-University Training Contest 8-1006 physics
- HDU 5319 Painter(模拟 + 规律)——2015 Multi-University Training Contest 3
- HDU 5795 A Simple Nim(SG打表找规律)——2016 Multi-University Training Contest 6
- HDU 5810 Balls and Boxes(打表找规律)——2016 Multi-University Training Contest 7 1002
- 2016 Multi-University Training Contest 8 1006 physics (物理+数学)
- hdu 5831 Rikka with Parenthesis II(2016 Multi-University Training Contest 8——模拟)
- 2017 Multi-University Training Contest 10 1002 Array Challenge HDU 6172(找规律 矩阵快速幂)
- hdu 5826 physics 2016 Multi-University 8
- 贪心 ( HDU 5821 )——2016 Multi-University Training Contest 8 1001
- hdu 5821 Ball(2016 Multi-University Training Contest 8——贪心+排序)
- 《STL系列》之vector原理及实现
- 116单向TSP
- Android-屏幕适配
- life will in "if......then"
- 【NOIP2016提高A组8.11】钱仓
- HDU 5826 physics(积分 找规律)——2016 Multi-University Training Contest 8
- 任意进制转换
- hdu 3999 The order of a Tree
- c++类的实例化
- 《STL系列》之map原理及实现
- BestCoder Round #86
- 解决android加载bitmap内存溢出的方法
- leetcode难度及面试频率
- Myeclipse加入反编译插件