HDU 5826(水题,物理公式推导,积分公式推导直接出结果)
来源:互联网 发布:如何在淘宝店发通告 编辑:程序博客网 时间:2024/04/28 12:20
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5826
题目描述很复杂,全是迷惑人的,重要的就用了一个初速度,其他的方向啦,初始位置啦都无所谓。
有物理公式V^2 - V0^2 = 2ax, 由C = Vi * Ai' 和 Xi = Vi * Ti; 则V^2 = V0^2 + 2 * A * V *T; 即 V ^2 = V0^2 + 2CT;
感悟:读题目抓住根本,快读。
C - physics
Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uDescription
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
#include <bits/stdc++.h>using namespace std;typedef pair<int, int> P;typedef long long LL;#define INF 0x3f3f3f3f#define PI acos(-1)#define MAX_N 10000#define LOCALLL v[100005];int main(){#ifdef LOCALfreopen("b:\\data.in.txt", "r", stdin);#endif int T; scanf("%d", &T); while(T--) { LL n, C;scanf("%I64d%I64d", &n, &C); LL x, d; for(int i = 0; i < n; i++) { scanf("%I64d%I64d%I64d", &v[i], &x, &d); } sort(v, v+n); //速度排序 int q; scanf("%d" ,&q); LL t, k; while(q--) { scanf("%I64d%I64d" ,&t, &k); //加速t秒,第k小的值 printf("%.3lf\n", sqrt(2.0 * C * t + v[k-1] * v[k-1])); } } return 0;}
0 0
- HDU 5826(水题,物理公式推导,积分公式推导直接出结果)
- HDU 5826 (物理公式推导)
- 公式推导
- HDU 5826 physics(公式推导+sort)
- HDU 2298 Toxophily(公式推导)
- 圆面积公式积分法推导
- 用分部积分推导梯形数值积分公式
- Hdu 2086 A1=?公式csflx推导
- hdu 4652 经典概率题+公式推导
- hdu 4565 公式推导+矩阵快速幂
- HDU 2421 Deciphering Password 公式推导
- 【HDU 1005 Number Sequence】+ 公式推导
- HDU 5858 Hard problem (公式推导)
- [HDU]4035 Maze 期望公式推导
- Catalan数公式推导
- 平方和公式推导
- 推导坐标旋转公式
- 点乘公式推导
- vim without extern
- DataGuard主备之间解决gap的步骤
- 构造数据类型简单介绍
- C# Control的Invoke和BeginInvoke
- JSP动作元素
- HDU 5826(水题,物理公式推导,积分公式推导直接出结果)
- 动态规划 - 九度OJ 1480
- css 利用阴影给字体加粗
- DataGuard主备归档存在gap的处理办法
- HDU 1232 畅通工程 (并查集)
- LeetCode 44. Wildcard Matching
- 关于springMVC中使用session的理解
- Spark与Pandas中DataFrame对比(详细)
- C#学习笔记(三)