physics

题目连接:

http://acm.hdu.edu.cn/showproblem.php?pid=5826

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.

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<=105,1<=Xi<=109

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

Hint

题意

给你n个球,以及球的位置,球初始方向,球保证都在x轴上。

而且V[i]*A[i] = C

现在有Q次询问,问你在第t秒,第k大的速度是多少。

题解:

弹性碰撞,那么其实就是交换速度,那么就和位置无关了。

第k大,其实就是开始速度第k大的球。

速度怎么求呢? V[i]*A[i] = C ,那么 Cdt = V[i]dV,然后积分 2k+2Ct = V[i]^2,把初速度带进去,把k解出来就好了。

(其实功率是守恒的,用这个做也很简单

代码

#include <bits/stdc++.h>

using namespace std;

int V[100010];
int n,c,t,k,q,T; double solve(int v,int t)
{
return (sqrt(1.0*v*v+2.0*t*c));
} int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&c);
for(int i=1;i<=n;i++)
{
int v,x,d;
scanf("%d%d%d",&v,&x,&d);
V[i]=v;
}
sort(V+1,V+1+n);
scanf("%d",&q);
while(q--)
{
scanf("%d%d",&t,&k);
printf("%.3f\n",solve(V[k],t));
}
}
return 0;
}

hdu 5826 physics 物理题的更多相关文章

  1. HDU 5826 physics(物理)

     physics(物理) Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)   D ...

  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 5761 Rower Bo 物理题

    Rower Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5761 Description There is a river on the Ca ...

  6. hdu 5066 小球碰撞(物理题)

    http://acm.hdu.edu.cn/showproblem.php?pid=5066 中学物理题 #include <cstdio> #include <cstdlib> ...

  7. [物理题+枚举] hdu 4445 Crazy Tank

    题意: 给你N个炮弹的发射速度,以及炮台高度H和L1,R1,L2,R2. 问任选发射角度.最多能有几个炮弹在不打入L2~R2的情况下打入L1~R1 注意:区间有可能重叠. 思路: 物理题,发现单纯的依 ...

  8. HDU 1155 Bungee Jumping(物理题,动能公式,弹性势能公式,重力势能公式)

    传送门: Bungee Jumping Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  9. Codeforces Round #114 (Div. 1) A. Wizards and Trolleybuses 物理题

    A. Wizards and Trolleybuses Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...

随机推荐

  1. Spring 学习01

    一.Spring概念 1 spring是开源的轻量级框架 2 spring核心主要两部分: (1)aop:面向切面编程,扩展功能不是修改源代码实现 (2)ioc:控制反转, - 比如有一个类,在类里面 ...

  2. Linux iptables常用命令的使用

    为什么会有本文 因为最近帮一个朋友布署一个上网梯子,他那边本来用的是v2ray,但是他想用ssr,但是安装配置ssr过程中出了很多问题,比如linux内核版本4.9有点老,不支持bbr加速.无法连接s ...

  3. dedecms在linux上安装提示没权限解决办法

    web服务器运行的用户与目录所有者用户必须不一样,比如apache运行的用户为root,那么网站目录设置的所有者就应该不能设置为root,而是设置不同于root的用户,如apache. 我们这里假设w ...

  4. Flex 经验笔记二

    向 Module 传递数据:好像只能传递些像 整型,字符型等简单类型的数据,也能传递像 json 这样的 Object 对象,但如果 Object 对象是从层的,其子级数据,好像也读取不到. func ...

  5. MFS - MooseFS 文件系统

    MFSMooseFS 文件系统 可以实现RAID 功能:节约成本 实现在线扩展:是一种半分布式文件系统. 一.MFS文件系统的组成 1.mfsmaster 元数据服务器. 在整个体系中负责管理管理文件 ...

  6. free vmstat查看内存及系统调优【转】

    内存查看 查看内存是否存在瓶颈,使用top指令看比较麻烦,而free命令更为直观: [/home/weber#]free total used free shared buffers cached M ...

  7. vue 兼容IE报错解决方案

    IE 页面空白 报错信息 此时页面一片空白 报错原因 Babel 默认只转换新的 JavaScript 语法(如箭头函数),而不转换新的 API ,比如 Iterator.Generator.Set. ...

  8. Linux 黑白界面显示

    2014年1月14日 15:47:47 不知道别人怎么看,反正我觉得黑白配显示很方便阅读 命令: ls 脚本: ~/.bashrc 指令: alias ls='ls --color=never' 命令 ...

  9. MVC5使用EF6 Code First--创建EF数据模型(一)

    此Web应用程序演示如何使用Entity Framework 6和Visual Studio 2015创建ASP.NET MVC 5应用程序.本教程使用“Code First ”即代码先行.有关如何在 ...

  10. Django Celery定时任务和时间设置

    1.Celery加入定时任务 Celery除了可以异步执行任务之外,还可以定时执行任务.在实例代码的基础上写个测试方法: #coding:utf- from celery.task.schedules ...