physics

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 817    Accepted Submission(s): 454

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 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<=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
 
Author
学军中学
 
Source
 
题目大意:

光滑的水平直线上有n个质量相等的小球,已知每个小球的初始位置,初始速度和方向,每个小球的每个时刻的加速度a都满足a*v=c,v是该时刻的速度,c是已知的

常数,小球之间的碰撞是完全碰撞(不明白就百度),然后q个询问,每次询问第t秒时速度第k小的小球速度是多少?

题解:

a = dv/dt = C/v

-----> vdv = Cdt

两边同时积分v是从v0-vt,t是从0到t

-----> [1/2*v^2] (v0---vt) = Ct  (0----t)

-----> v = sqrt(2*C*t+v0^2);

#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<cmath>
#include<vector>
using namespace std; struct node
{
double v,x,d;
}a[]; int T,n,q,t,k;
double c; bool cmp(node a, node b)
{
return a.v<b.v;
}
int main()
{
scanf("%d",&T);
for(;T>;T--)
{
scanf("%d%lf",&n,&c);
for(int i=;i<=n;i++)
scanf("%lf%lf%lf",&a[i].v,&a[i].x,&a[i].d); scanf("%d",&q);
sort(a+,a++n,cmp);
for(;q>;q--)
{
scanf("%d%d",&t,&k);
double v=a[k].v;
printf("%.3lf\n",sqrt(v*v+*c*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(物理) Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)   D ...

  3. hdu 5826 physics 物理题

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

  4. HDU 5826 physics

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

  5. hdu 1724 Ellipse simpson积分

    /* hdu 1724 Ellipse simpson积分 求椭圆的部分面积 simpson积分法 http://zh.wikipedia.org/zh-tw/%E8%BE%9B%E6%99%AE%E ...

  6. hdu 5826 (物理) physics

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

  7. hdu 1724 Ellipse——辛普森积分

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724 #include<cstdio> #include<cstring> #in ...

  8. HDU 1724 Ellipse ——Simpson积分

    [题目分析] 一看题目,直接把椭圆积分起来就可以了嘛. 然后发现椭圆比较难积分,还是算了吧. 用Simpson积分硬上. 大概就是用二次函数去拟合面积. [代码] #include <cstdi ...

  9. HDU 1724 Ellipse [辛普森积分]

    Ellipse Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

随机推荐

  1. C++ char float int string 之间的转换

    string str = "123"; string 转 int int i = atoi( str.c_str() ); string 转 float float f = ato ...

  2. HTTPS复习

    Https Https其实是两个协议,即HTTP协议和SSL协议,但是由于HTTP协议应用广泛,而且需要为其提供数据隐私保护,所以将HTTP协议与SSL协议结合.HTTP属于应用层,在远古时代,它只需 ...

  3. ServletConfig获取Servlet的公共参数方法

    web.xml配置: <servlet> <servlet-name>AServlet</servlet-name> <servlet-class>AS ...

  4. 解决“检测到有潜在危险的Request.Form值”

    先看如下 web.config 的代码: <system.web>     <compilation debug="true" targetFramework=& ...

  5. 为什么修改Host不生效

    开发验证的好好的功能,提测后经常有测试反应功能有bug.很多原因都是测试切换host没生效造成的,为什么切换host后刷新页面了也没生效呢? 不生效原因: Keep-Alive 服务器在响应头设置了 ...

  6. Redis学习笔记之Redis单机,伪集群,Sentinel主从复制的安装和配置

    0x00 Redis简介 Redis是一款开源的.高性能的键-值存储(key-value store).它常被称作是一款数据结构服务器(data structure server). Redis的键值 ...

  7. BIOS/MBR UEFI/GPT关系与区别-资料整理

    ---恢复内容开始--- 关于 BIOS/MBR UEFI/GPT他们之间的关系一直比较疑惑, 首先一点前提 BIOS UEFI 是一类,是控制硬件,引导启动的:MBR GPT是硬盘的分区定义.. 后 ...

  8. 20145314郑凯杰 《Java程序设计》第8周学习总结

    20145314郑凯杰 <Java程序设计>第8周学习总结 教材学习内容总结 代码已托管 第十五章 通用API ①日志: 日志对信息安全意义重大,审计.取证.入侵检测等都会用到日志信息 使 ...

  9. (转)C#自制Web 服务器开发:用C#开发自己的Web服务器

    当输入:127.0.0.1:5050 GET / HTTP/1.1 Accept: text/html, application/xhtml+xml, */* Accept-Language: zh- ...

  10. rocketmq事务消息

    rocketmq事务消息 参考: https://blog.csdn.net/u011686226/article/details/78106215 https://yq.aliyun.com/art ...