hdu 5826 physics 物理题
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 物理题的更多相关文章
- 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 (物理数学,积分)
physics Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
- HDU 5826 physics
该问题和xi,di均无关,碰撞只会使得速度反向,大小不会变.因此只要计算速度. #pragma comment(linker, "/STACK:1024000000,1024000000&q ...
- hdu 5761 Rower Bo 物理题
Rower Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5761 Description There is a river on the Ca ...
- hdu 5066 小球碰撞(物理题)
http://acm.hdu.edu.cn/showproblem.php?pid=5066 中学物理题 #include <cstdio> #include <cstdlib> ...
- [物理题+枚举] hdu 4445 Crazy Tank
题意: 给你N个炮弹的发射速度,以及炮台高度H和L1,R1,L2,R2. 问任选发射角度.最多能有几个炮弹在不打入L2~R2的情况下打入L1~R1 注意:区间有可能重叠. 思路: 物理题,发现单纯的依 ...
- HDU 1155 Bungee Jumping(物理题,动能公式,弹性势能公式,重力势能公式)
传送门: Bungee Jumping Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Othe ...
- 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 ...
随机推荐
- [iOS问题归总]iPhone上传项目遇到的问题
1. 在上传项目的时候,UpLoad App Store后弹出iTunes Store operation failed. 错误原因:你在ItunesConnect(https://itunescon ...
- js调试系列: 控制台命令行API
js调试系列目录: - 上次初步介绍了什么是控制台,以及简单的 console.log 输出信息.最后还有两个小问题,我们就当回顾,来看下怎么操作吧. 先打开百度,然后按 F12 打开后,如果不是 C ...
- 一个由SEO优化展开的meta标签大讲解
您的个人网站即使做得再精彩,在“浩瀚如海”的网络空间中,也如一叶扁舟不易为人发现,如何推广个人网站,人们首先想到的方法无外乎以下几种: ● 在搜索引擎中登录自己的个人网站 ● 在知名网站加入你个人网站 ...
- asp.net分页之AJAX 分页
查询功能是开发中最重要的一个功能,大量数据的显示,我们用的最多的就是分页. 在ASP.NET 中有很多数据展现的控件,比如Repeater.GridView,用的最多的GridView,它同时也自带了 ...
- Python 入门基础2 --基本数据类型、运算符
本节目录 一.IDE(集成环境的安装) 二.基本数据类型 三.输入输出 四.运算符 五.后期补充内容 一.IDE(集成环境的安装) 安装pycharm 注:快捷键: 1.ctrl + ? :注释此行, ...
- 阿里云RDS的mysql数据库占用空间超过90%的处理
阿里云RDS数据库最大支持2T,目前已经占用了90%,如果进行分库或者迁移比较麻烦,思路是找出占用空间过大的日志或不重要的文件进行删除操作 查询所有数据库占用磁盘空间大小的SQL语句: show bi ...
- 在VMware上安装Ubuntu软件步骤与遇到的相关问题及解决方案
图解演示环境版本: 本机系统: WIN10 虚拟机:VMware Workstation 12(中文版) 安装目标:Ubuntu Desktop 12.04 LTS (请点击这里)先下载好iso镜像 ...
- windows安装 Microsoft Visual c++
第一种方法: 第二种方法: 参考链接 直接给一个2015版本的下载地址 https://blogs.msdn.microsoft.com/pythonengineering/2016/04/11/un ...
- 不使用第三方软件、使用IE11自带功能来屏蔽浏览器广告
第一步: 下载后面的附件http://files.cnblogs.com/limits/IE11%E5%8E%BB%E5%B9%BF%E5%91%8A.zip 打开此路径IE11跟踪保护+CSS去广告 ...
- linux开启远程访问端口
开启3306端口的tcp访问权限 /sbin/iptables -I INPUT -p tcp -dport 3306 -j ACCEPT 保存防火墙信息 /etc/rc.d/init.d/iptab ...