hdu 5826 physics (物理数学,积分)
physics
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 817 Accepted Submission(s): 454
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.
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
光滑的水平直线上有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 (物理数学,积分)的更多相关文章
- HDU 5826 physics (积分推导)
physics 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5826 Description There are n balls on a smoo ...
- HDU 5826 physics(物理)
physics(物理) Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) D ...
- hdu 5826 physics 物理题
physics 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5826 Description There are n balls on a smoo ...
- HDU 5826 physics
该问题和xi,di均无关,碰撞只会使得速度反向,大小不会变.因此只要计算速度. #pragma comment(linker, "/STACK:1024000000,1024000000&q ...
- hdu 1724 Ellipse simpson积分
/* hdu 1724 Ellipse simpson积分 求椭圆的部分面积 simpson积分法 http://zh.wikipedia.org/zh-tw/%E8%BE%9B%E6%99%AE%E ...
- hdu 5826 (物理) physics
题目:这里 题意:光滑的水平直线上有n个质量相等的小球,已知每个小球的初始位置,初始速度和方向,每个小球的每个时刻的加速度a都满足a*v=c,v是该时刻的速度,c是已知的 常数,小球之间的碰撞是完全碰 ...
- hdu 1724 Ellipse——辛普森积分
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1724 #include<cstdio> #include<cstring> #in ...
- HDU 1724 Ellipse ——Simpson积分
[题目分析] 一看题目,直接把椭圆积分起来就可以了嘛. 然后发现椭圆比较难积分,还是算了吧. 用Simpson积分硬上. 大概就是用二次函数去拟合面积. [代码] #include <cstdi ...
- HDU 1724 Ellipse [辛普森积分]
Ellipse Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
随机推荐
- 今天刚接触lua 写写环境配置和基本设置
首先是安装开发工具: Quick: http://www.tairan.com/engines-download 引擎 Sublime Text的下载地址为:http://www.sublimetex ...
- eclipse中添加tomcat ServerName 无法输入
Eclipse的开发过程中,无法从以下方式,添加Tomcat服务器. 其中ServerName是被置为灰色的,无法编辑. 如何解决 1. 关闭Eclipse 2. 打开WorkSpace所在的 ...
- WEB项目异常处理
package cn.rest.advice; import javax.servlet.http.HttpServletResponse; import org.slf4j.Logger;impor ...
- 如何做好Web接口测试
说说我在测试接口时遇到的一些需要注意的点: 1.接口返回:数据格式是否与预期一致.例如:要求返回json格式的数据,json数据的key命名是否正确,对应的value是否与数据库一致.需要转换的数据是 ...
- JS正则表达式从入门到入土(5)—— 量词
量词 很多时候,我们需要匹配一个连续出现很多次字符的字符串,比如,我们要匹配一个连续出现20次的数字的字符串,按照之前的写法: \d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d ...
- [NOI2014]起床困难综合症(二进制+贪心)
题目 [NOI2014]起床困难综合症 做法 先用全\(0\)和全\(1\)去运行一下,再在满足\(m\)的限制下,贪心地从高位到低位选择即可
- 枚举转SelectList扩展方法
public enum Avbc { Red=1, Blue=2, Whilt=3, Black=4 } public st ...
- MVC通过服务端对数据进行验证(和AJAX验证一样)
在实体类中 添加 Remote属性,指定用某个View下的某个方法进行验证,如下面表示用User控制器中的UserExiting方法验证 public class User { [Remot ...
- 20145211 《网络渗透》MS08_067安全漏洞
20145211 <网络渗透>MS08_067安全漏洞 一.实验原理 ms08_067是服务器服务中一个秘密报告的漏洞,于2008年被发现.攻击者利用靶机默认开放的SMB服务的445端口, ...
- sudo fdisk -l
施其振 2015/1/31 22:06:26 第一行十大5 施其振 2015/1/31 22:06:39 第一行sda5 施其振 2015/1/31 22:06:49 是你的固态硬盘 施其振 20 ...