hdu 5826 physics(2016 Multi-University Training Contest 8——积分求解)
来源:互联网 发布:淘宝冲销量网站 编辑:程序博客网 时间:2024/05/18 01:12
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5826
physics
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 132 Accepted Submission(s): 92
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
题目大意:给n个球的初始位置,速度,方向,问t秒之后的第k小的速度是多少;
解题思路:
积分求解:
具体过程如图所示。
详见代码。
#include <iostream>#include <cstdio>#include <algorithm>#include <cmath>using namespace std;#define N 100010double v[N];int x[N],d[N];int main(){ int T; scanf("%d",&T); while (T--) { int n,c,q,t,k; scanf("%d%d",&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); scanf("%d",&q); for (int i=0; i<q; i++) { scanf("%d%d",&t,&k); double ans=sqrt((1.0*2*c *t+v[k]*v[k]*1.0)*1.0); printf ("%.3lf\n",ans); } } return 0;}
0 0
- hdu 5826 physics(2016 Multi-University Training Contest 8——积分求解)
- HDU 5826 physics(积分 找规律)——2016 Multi-University Training Contest 8
- 2016 Multi-University Training Contest 8-1006 physics
- 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——贪心+排序)
- hdu 5831 Rikka with Parenthesis II(2016 Multi-University Training Contest 8——模拟)
- [HDU5826] physics [2016 Multi-University Training Contest 8(2016多校联合训练8) 1006]
- 2016 Multi-University Training Contest 8 1006 physics (物理+数学)
- HDU 5821 Ball 2016 Multi-University Training Contest 8
- hdu 5821 2016 Multi-University Training Contest 8(排序)
- 2016 Multi-University Training Contest 8 题解
- hdu 5733 tetrahedron(2016 Multi-University Training Contest 1——几何公式题)
- hdu 5723 Abandoned country(2016 Multi-University Training Contest 1——最小生成树+深搜)
- 数学——Acperience ( HDU 5734) ( 2016 Multi-University Training Contest 2 1001 )
- hdu 5734 Acperience(2016 Multi-University Training Contest 2——化简公式,数学推导)
- 欧拉定理——PowMod ( HDU 5728 )(2016 Multi-University Training Contest 1 1006)
- hdu 5745 La Vie en rose(2016 Multi-University Training Contest 2——暴力)
- ACdream1062
- 【1】【栈模拟】HDU5831 Rikka with Parenthesis II
- Oracle至Sql Server用DB Link查询缓慢原因之一
- sed命令
- foxmail小记
- hdu 5826 physics(2016 Multi-University Training Contest 8——积分求解)
- 有关json和xml报文的解析和构造
- HDU 1006 Tick and Tick
- C#从html网页内容中提取指定个数的汉字
- c#的接口
- 如何使用Qt插件在Qt中进行ROS开发
- install yii2 for php 5.4 on CentOS 7
- 【stm32f103-学习笔记】测试看门狗
- 二次指数平滑法求预测值的Java代码