题意

有一个竖直的管子内有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


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]的更多相关文章

  1. poj 3684 Physics Experiment 弹性碰撞

    Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1489   Accepted: 509 ...

  2. Greedy:Physics Experiment(弹性碰撞模型)(POJ 3848)

    物理实验 题目大意:有一个与地面垂直的管子,管口与地面相距H,管子里面有很多弹性球,从t=0时,第一个球从管口求开始下落,然后每1s就会又有球从球当前位置开始下落,球碰到地面原速返回,球与球之间相碰会 ...

  3. POJ 3684 Physics Experiment(弹性碰撞)

    Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2936   Accepted: 104 ...

  4. POJ3684 Physics Experiment 【物理】

    Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1031   Accepted: 365 ...

  5. [POJ3684]Physics Experiment

      Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1363   Accepted: 476   Special Judge ...

  6. poj 3684 Physics Experiment(数学,物理)

    Description Simon ), the first ball is released and falls down due to the gravity. After that, the b ...

  7. POJ:3684-Physics Experiment(弹性碰撞)

    Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3392 Accepted: 1177 Sp ...

  8. Physics Experiment(POJ 3684)

    原题如下: Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3583   Accepte ...

  9. POJ 3684 Physics Experiment

    和蚂蚁问题类似. #include<cstdio> #include<cstring> #include<cmath> #include<vector> ...

随机推荐

  1. ComboBox下拉列表框

    属性:DropDownStyle(下拉.可编辑等).Items(条目) 事件:SelectedIndexChanged选择项改变触发 Items内容:总经理.副总经理.财务部 DropDownStyl ...

  2. Neo4j 第一篇:在Windows环境中安装Neo4j

    图形数据库(Graph Database)是NoSQL数据库家族中特殊的存在,用于存储丰富的关系数据,Neo4j 是目前最流行的图形数据库,支持完整的事务,在属性图中,图是由顶点(Vertex),边( ...

  3. Entity Framework入门教程(19)---EF中使用事务

    EF中使用事务 这节介绍EF6中事务的使用.EF core中事务的使用方式和EF6中一模一样. 1.EF中的默认的事务 默认情况下,当我们执行一个SaveChanges()方法时就会新建了一个事务,然 ...

  4. ruby 对象转换哈希(Hash)

    通过 ActiveRecord 从数据库的某张数据表(table)中获取的对象如何转换成为 Hash orders_table 是一张订单信息表,对应的 model 为 Orders @order = ...

  5. 模板方法模式-Template Method(Java实现)

    模板方法模式-Template Method 在模板模式中, 处理的流程被定义在父类中, 而具体的处理则交给了子类. 类关系图很简单: Template接口 这里定义了子类需要实现的方法(before ...

  6. PageRank算法--从原理到实现

    本文将介绍PageRank算法的相关内容,具体如下: 1.算法来源 2.算法原理 3.算法证明 4.PR值计算方法 4.1 幂迭代法 4.2 特征值法 4.3 代数法 5.算法实现 5.1 基于迭代法 ...

  7. [简洁]JavaScript中添加、移除、移动、复制、创建和查找节点元素

    查找: document.getElementsByTagName通过标签名获取元素,不论有多少个都返回元素集合. document.getElementsByClassName通过类名获取元素,同上 ...

  8. 忘记mysql的登陆密码该怎么办?

    1.如果忘记了其他用户的密码,可以使用root账户进入mysql,修改mysql.user表中的用户密码 2.如果忘记了root的mysql密码,可以使用如下方式: 确认服务器处于安全的状态,也就是没 ...

  9. Windows下的wget,命令行下载url

    1.进命令行(Win + R,输入"cmd") 2.输入:start powershell 3.等待PowerShell窗口启动 4.PowerShell窗口依次输入: $clie ...

  10. Gradle part1 HelloWorld

    (https://spring.io/guides/gs/gradle/#scratch) ----gradle helloworld----- 1.下载后安装 Unzip the file to y ...