HDU 5826 physics物理

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

 

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.

在一个光滑水平直线轨道上有n个小球。轨道可以被当做一条直线。小球可以被当做质量相同的质点。

最初,小球i在位置Xi。其初速度大小为Vi,速度方向为Di。(Di∈−1,1)

给定常量C。任意时刻,小球的加速度Ai与速度Vi同方向,并十分玄学地满足等式Ai * Vi = C。

有多个小球,他们可能在运动过程中发生碰撞。我们假定所有碰撞均为完全弹性碰撞。

有多次询问,每次询问有两个整数t与k。我们的任务是找出所有小球开始运动t秒后第k小的速度。

* 完全弹性碰撞 : 在碰撞中不损失动能即为完全弹性碰撞。

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

第一行为一个整数T,表示测试用例的数量。

对于每个测试用例,第一行有两个整数n <= 10^5 与 C <= 10^9。

随后n行。第i行有三个整数Vi,Xi,Di。Vi表示球i的初速度大小。Xi表示球i的初始位置。Di表示球i的运动方向。

下一行有一个整数q <= 10^5,表示询问的数量。

随后q行。每行有两个整数 t <= 10^9 与 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 - 输出样例

1

3 7

3 3 1

3 10 -1

2 7 1

3

2 3

1 2

3 3

6.083

4.796

7.141

【题解】

  加速每一个小球都有一个初始状态,因为A*V=C,所以所有球的当前状态只和初始状态的后t秒有关。

  把题目给的表达式转成和时间t有关的函数。

    A(t) *V(t)  = C

  速度的变化率也就是加速度,即A(t) = V’(t)

  带入上面的式子

    V’(t)*V(t) =  C

  然后求不定积分,求原函数…………(反正我只会求导所以默默地逆向)

    V(t)*V(t)/2 = Ct

    V(t) = 

  如果有常数什么的话就不管了,反正都能通过移动t来达到相应的速度。

  根据动量定理,小球碰撞之后只是交换速度,其实没有什么变化,所以位置和速度方向就不用管了。

  把每个小球的初始速度换算成t,t越大速度越快,可以得到小球速度的排名。每次查询时间的增量是固定,因此不影响排名。

【代码 C++】

 #include <cstdio>
#include <algorithm>
#include <cmath>
double data[];
int main(){
__int64 T, n, c, v, i, t, k;
char r[];
scanf("%I64d", &T);
while (T--){
scanf("%I64d%I64d", &n, &c); c <<= ;
for (i = ; i <= n; ++i){
scanf("%I64d", &v); gets(r);
data[i] = (double)v*v / c;
}
std::sort(data + , data + n + );
scanf("%I64d", &n);
while (n--){
scanf("%I64d%I64d", &t, &k);
printf("%.3lf\n", sqrt(c*(data[k] + t)));
}
}
return ;
}

HDU 5826 physics(物理)的更多相关文章

  1. hdu 5826 physics 物理题

    physics 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5826 Description There are n balls on a smoo ...

  2. HDU 5826 physics (积分推导)

    physics 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5826 Description There are n balls on a smoo ...

  3. hdu 5826 physics (物理数学,积分)

    physics Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Sub ...

  4. HDU 5826 physics

    该问题和xi,di均无关,碰撞只会使得速度反向,大小不会变.因此只要计算速度. #pragma comment(linker, "/STACK:1024000000,1024000000&q ...

  5. hdu 5826 (物理) physics

    题目:这里 题意:光滑的水平直线上有n个质量相等的小球,已知每个小球的初始位置,初始速度和方向,每个小球的每个时刻的加速度a都满足a*v=c,v是该时刻的速度,c是已知的 常数,小球之间的碰撞是完全碰 ...

  6. Physics(物理系统)

    物理: Physics            Box2d   Unity 内置NVDIA PhysX物理引擎 刚体:要使一个物体在物理控制下,简单添加一个刚体给它.这时,物体将受重力影响,并可以与其他 ...

  7. SPRITEKIT游戏框架之关于PHYSICS物理引擎属性

    Spritekit提供了一个默认的物理模拟系统,用来模拟真实物理世界,可以使得编程者将注意力从力学碰撞和重力模拟的计算中解放出来,通过简单地代码来实现物理碰撞的模拟,而将注意力集中在更需要花费精力的地 ...

  8. hdu 5144(三分+物理)

    NPY and shot Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  9. Just a Joke HDU - 4969(物理+积分)

    题目链接:https://vjudge.net/problem/HDU-4969#author=0 题意:一个人在圆心以V2速度追赶一个以V1的速度进行圆周运动,问在圆心的人能否在不超过D的距离追上他 ...

随机推荐

  1. 关于UIWindow(转)

    (原文出自:http://www.cnblogs.com/wendingding/p/3770052.html,特别感谢) 一:[[UIScreen mainScreen] bounds] 和[UIS ...

  2. linux curl用法详解

    linux ‍‍curl用法详解 ‍‍curl的应用方式,一是可以直接通过命令行工具,另一种是利用libcurl库做上层的开发.本篇主要总结一下命令行工具的http相关的应用, 尤其是http下载方面 ...

  3. Java程序编译和运行的过程【转】

    转自:http://www.360doc.com/content/14/0218/23/9440338_353675002.shtml Java整个编译以及运行的过程相当繁琐,本文通过一个简单的程序来 ...

  4. centos6.5 64bit 实现root开机自动登录X桌面

    vim /etc/gdm/custom.conf 修改daemon节点,添加如下内容: AutomaticLoginEnable=true AutomaticLogin=root 重启计算机. 完.

  5. jquery easyui读取json文件乱码

    输出的json要求用utf-8,否则因json的编码格式有问题显示不了中文.记事本默认编码是ANSI,若保存的json是由记事本改后的缀名,则json格式有问题,显示中文为乱码. 解决方法:打开.js ...

  6. postgresql压力测试工具用法以及参数解读

    pgbench是PostgreSQL自带的一个数据库压力测试工具, 支持TPC-B测试模型, 或自定义测试模型. 自定义测试模型支持元命令, 调用shell脚本, 设置随机数, 变量等等. 支持3种异 ...

  7. js 表单操作

    order.aspx 订单页-  order-detail.aspx订单确认页-  操作:order.aspx提交订单@1,跳转到order-detail.aspx页面,确认页面操作:返回上一步@2- ...

  8. java中基础类型的初始值,以及一些平时不注意的小知识

    有时候总是卡在一些类型的初始值上,今天闲下来就来自己给自己记录一下. String   a; 如果直接打印会提示未初始化.并且未初始化的a不能比较. 这时,我们定义个person类 person{ S ...

  9. 利用Session实现一次验证码

    Session可避免表单的重复提交:实现一次表单提交,可避免恶意提交: 1.首先建立一个Servlet类:ValidateColorServlet,里边有获取验证码的方法,并且验证码是大小写区分: p ...

  10. 谷歌Chrome浏览器如何设置网页的默认编码方法

    设置->高级->自定义字体->编码->utf-8