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. 【android】来电悬浮窗

    先看下效果图 说下思路: 1:监听来电广播 2:根据来电号码,和本地数据库做匹配,有记录的,则提取出头像.名字.职位,生成悬浮窗 3:监听来电广播,如果当前行为是空闲的(没有任何通话行为),则删除掉悬 ...

  2. servlet的总结

    tomcat在启动的时候 加载webapp下面的web.xml,加载里面定义的servlet. web.xml文件有两部分:servlet类定义和servlet映射定义每个被载入的servlet类都有 ...

  3. CentOS系统下yum命令的详细使用方法

    yum是什么yum = Yellow dog Updater, Modified 主要功能是更方便的添加/删除/更新RPM包. 它能自动解决包的倚赖性问题. 它能便于管理大量系统的更新问题 yum特点 ...

  4. 为什么Eureka Client获取服务实例这么慢

    1. Eureka Client注册延迟 Eureka Client启动后不会立即向Eureka Server注册,而是有一个延迟时间,默认为40s 2. Eureka Server更新响应缓存 Eu ...

  5. 快速升级openwrt的linux内核版本

    一.分析 要升级openwrt的linux内核版本,关键是要制作内核配置文件 二.内核配置文件制作方法 2.1当前openwrt对应的某个开发板有对应的内核配置文件,比如此时的openwrt的linu ...

  6. KVM配置及维护

    kvm使用场景 1.公司测试环境/开发环境 测试开发环境可以使用配置低点的物理机就可以 2.公司生产环境 一般小公司没有私有云或容器团队,运维人员可能就1-2个,然后公司也不舍得花钱买商业化的私有云. ...

  7. OAuth客户端调用

    public class OAuthClientTest { private HttpClient _httpClient; public OAuthClientTest() { _httpClien ...

  8. SQL优化的若干原则

    SQL语句:是对数据库(数据)进行操作的惟一途径:消耗了70%~90%的数据库资源:独立于程序设计逻辑,相对于对程序源代码的优化,对SQL语句的优化在时间成本和风险上的代价都很低:可以有不同的写法:易 ...

  9. 【cs231n】卷积神经网络

    较好的讲解博客: 卷积神经网络基础 深度卷积模型 目标检测 人脸识别与神经风格迁移 译者注:本文翻译自斯坦福CS231n课程笔记ConvNet notes,由课程教师Andrej Karpathy授权 ...

  10. Linux 安装rabbitmq 遇到的一些问题

    Linux下防火墙开启相关端口及查看已开启端口 https://www.cnblogs.com/pizitai/p/6518987.htmlhttps://www.cnblogs.com/blog-y ...