Physics Experiment 弹性碰撞 [POJ3684]
题意
有一个竖直的管子内有n个小球,小球的半径为r,最下面的小球距离地面h高度,让小球每隔一秒自由下落一个,小球与地面,小球与小球之间可视为弹性碰撞,让求T时间后这些小球的分布
Input
The first line of the input contains one integer C (C ≤ 20) indicating the number of test cases. Each of the following lines contains four integers N, H, R, T.
1≤ N ≤ 100.
1≤ H ≤ 10000
1≤ R ≤ 100
1≤ T ≤ 10000
Output
For each test case, your program should output N real numbers indicating the height in meters of the lowest point of each ball separated by a single space in a single line. Each number should be rounded to 2 digit after the decimal point.
Sample Input
2
1 10 10 100
2 10 10 100
Sample Output
4.95
4.95 10.20
Analysis
首先这种弹性碰撞的题可以很快联想到两只蚂蚁擦肩而过的题,但是这是有半径的,是与之前视为质点的情况是不同的,如何处理?
我们根据弹性碰撞,有动量守恒和机械能守恒,得到1,2两个求撞后的速度分别为
V1'=2*(m1-m2)/(m1+m2)*V1+2*m2/(m1+m2)*V2
V2'=2*(m2-m1)/(m1+m2)*V2+2*m1/(m1+m2)*V1
那也就是1,2两个小球发生了速度交换。
我们不妨设1为下面的求,2为上面的球,那么碰撞后(相互穿越),1的重力势能瞬间增加2mgr,速度不变,2的重力势能瞬间减少2mgr,速度也不变
所以我们可以把他等效于就相当于没有半径的情况+某球下面的球的数量×2r
对于计算位置,我们由H=1/2gt2可得,t=√(2H/g)
我们令k是满足kt<=T的最大正整数,那么
ansH= H-1/2g(T-kt)2 (k&2==0)
H-1/2g((k+1)t-T)2 (k&2==1)
Code
#include<cstdio>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include<map>
#include <algorithm>
#include <set>
using namespace std;
#define MM(a) memset(a,0,sizeof(a))
typedef long long LL;
typedef unsigned long long ULL;
const int mod = ;
const double eps = 1e-;
const int inf = 0x3f3f3f3f;
const double g=;
int cas,n,h,r,t,k;
double t0,tx,a[],temp;
double solve(int x)
{
if(x<) return h;
t0=sqrt(*h*1.0/g);
k=int(x/t0);
if(k%==) temp=x-k*t0;
else temp=t0-(x-k*t0);
return h-0.5*g*temp*temp;
}
int main()
{
cin>>cas;
while(cas--)
{
scanf("%d %d %d %d",&n,&h,&r,&t);
for(int i=;i<=n;i++)
a[i]=solve(t-(i-));
sort(a+,a+n+);
for(int i=;i<=n;i++)
printf("%.2f%c",a[i]+*(i-)*r/100.0,i==n?'\n':' ');//注意%s输出字符串,%c输出字符,所以这个地方不能用“”
} //因为%c无法输出“”字符串
return ;
}
Physics Experiment 弹性碰撞 [POJ3684]的更多相关文章
- poj 3684 Physics Experiment 弹性碰撞
Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1489 Accepted: 509 ...
- Greedy:Physics Experiment(弹性碰撞模型)(POJ 3848)
物理实验 题目大意:有一个与地面垂直的管子,管口与地面相距H,管子里面有很多弹性球,从t=0时,第一个球从管口求开始下落,然后每1s就会又有球从球当前位置开始下落,球碰到地面原速返回,球与球之间相碰会 ...
- POJ 3684 Physics Experiment(弹性碰撞)
Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2936 Accepted: 104 ...
- POJ3684 Physics Experiment 【物理】
Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1031 Accepted: 365 ...
- [POJ3684]Physics Experiment
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1363 Accepted: 476 Special Judge ...
- poj 3684 Physics Experiment(数学,物理)
Description Simon ), the first ball is released and falls down due to the gravity. After that, the b ...
- POJ:3684-Physics Experiment(弹性碰撞)
Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3392 Accepted: 1177 Sp ...
- Physics Experiment(POJ 3684)
原题如下: Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3583 Accepte ...
- POJ 3684 Physics Experiment
和蚂蚁问题类似. #include<cstdio> #include<cstring> #include<cmath> #include<vector> ...
随机推荐
- openstack项目【day23】:keystone组件网关协议
本节内容 一 静态页面和动态页面 二 什么是web server 三 什么是网关协议 3.1 引子 3.2 网关协议 四 网关协议CGI.FastCGI.WSGI.UWSGI 五 网关协议与keyst ...
- deepin 下安装goland中文字体显示全是方块
下载中文字体 apt-get install ttf-arphic-uming xfonts-intl-chinese 替换goland的汉化包,两个jar包.https://blog.csdn.ne ...
- JGUI源码:Accordion折叠到侧边栏实现(6)
折叠和非折叠效果如左右图所示 代码如下 //折叠 $.fn.jAccordionfold = function() { return this.each(function() { var obj = ...
- [家里蹲大学数学杂志]第057期图像复原中的改进 TV 模型
$\bf 摘要$: 本文给出了王大凯等编的<图像处理中的偏微分方程方法>第 6.2 节的详细论述. $\bf 关键词$: 图像复原; TV 模型; matlab 编程 1. 前言 图像在形 ...
- Centos7 安装 jdk 1.8
Centos7 安装 jdk 1.8 1.下载安装包 链接: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloa ...
- 【归纳】正则表达式及Python中的正则库
正则表达式 正则表达式30分钟入门教程 runoob正则式教程 正则表达式练习题集(附答案) 元字符\b代表单词的分界处,在英文中指空格,标点符号或换行 例子:\bhi\b可以用来匹配hi这个单词,且 ...
- Jumpserver(堡垒机)的安装与应用
官网:http://docs.jumpserver.org/zh/docs/introduce.html 作者:邓聪聪 环境 系统: CentOS 7.6 IP: 172.16.16.2 关闭 sel ...
- 【原创】大叔问题定位分享(30)mesos agent启动失败:Failed to perform recovery: Incompatible agent info detected
mesos agent启动失败,报错如下: Feb 15 22:03:18 server1.bj mesos-slave[1190]: E0215 22:03:18.622994 1192 slave ...
- iOS 中的屏幕旋转shouldAutorotate和supportedInterfaceOrientations的先后关系
这2个UIViewController的属性,都和旋转相关, 当设备发生旋转时,首先会查看根controller的shouldAutorotate是否允许旋转,如果允许,再通过 supportedIn ...
- Django-瀑布流
1.通过ajax方式实现滚动条瀑布流(1)创建数据库:xixi\pubu\models.py from django.db import models #Img图片表 class Img(models ...