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 ...
随机推荐
- Bar Mitzvah Attack分析
结合RC4算法实现,简单分析一下Bar Mitzvah Attack攻击的原理,并以WEP破解过程来举例说明通用的破解方式.(个人觉得RC4早已经过时,要想避免该攻击,应该采用更好的加密算法,如:cc ...
- android解决setOnItemClickListener没有响应
今天遇到一种情况,抽屉式导航栏里的listView的点击事件没有响应点击事件. 查看了下,原来是因为抽屉式导航栏的fragment声明,放在了内容fragment之前,导致点击动作被内容fragmen ...
- unity手势插件《FingerGestures 》使用入门
什么是FingerGestures? FingerGestures是Unity上,非常热门的一款用于处理用户输入的插件 为什么要使用FingerGestures? 1:它统一了鼠标点击和用户触摸的输入 ...
- TOSCA自动化测试工具视频资料
https://www.udemy.com/ search 'TOCSA' 找到两个免费资料学习
- etcd:从应用场景到实现原理的全方位解读 转自infoq
转自 infoq etcd:从应用场景到实现原理的全方位解读 http://www.infoq.com/cn/articles/etcd-interpretation-application-scen ...
- 一只代码小白git托管路上的二三事
[经验]一只代码小白git托管路上的二三事 写在前面的话 寒假的时候,娄老师给我们布置了代码托管的作业,并要求把托管地址发给学委.因假期的时候没有带电脑回家,所以只是在手机上草草注册了,也稀里糊涂就将 ...
- HDFS数据块
磁盘也是由数据块组成的,一般默认大小是512字节,构建磁盘之上的文件系统一般是磁盘块的整数倍. HDFS也是采用块管理的,但是比较大,在Hadoop1.x中默认大小是64M,Hadoo ...
- Web前端学习笔记之jQuery选择器
JQuery过滤器 经过一晚上的查找整理,终于整理出一套应该算最全面的JQuery选择过滤器的方法了.所有代码均经过测试.首先HTML代码 HTML Code <html><head ...
- linux 安装vscode
滚动安装vscode 需要先添加源,然后install 以centos为例: sudo rpm --import https://packages.microsoft.com/keys/microso ...
- uboot dm9000驱动故障
手头有一块6410开发板,已经有别人提供的uboot代码(基于2011.06),但是在检测dm9000时显示下面的输出: Net: No ethernet found. 当然其他网络命令例如ping等 ...