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

Description

Simon is doing a physics experiment with N identical balls with the same radius of R centimeters. Before the experiment, all N balls are fastened within a vertical tube one by one and the lowest point of the lowest ball is H meters above the ground. At beginning of the experiment, (at second 0), the first ball is released and falls down due to the gravity. After that, the balls are released one by one in every second until all balls have been released. When a ball hits the ground, it will bounce back with the same speed as it hits the ground. When two balls hit each other, they with exchange their velocities (both speed and direction).

Simon wants to know where are the N balls after T seconds. Can you help him?

In this problem, you can assume that the gravity is constant: g = 10 m/s2.

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 NHRT.
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

Source

 

THINKING

  如同POJ1852(ANTS)一样,当R=0时,可认为两个球碰撞后是互相交错而继续运动,当R=0时,处理方法相同,对于从下方开始的第i个球,在R=0的计算上加上d=2*r就好了。

const g:real=;

var a:array[..] of real;
n,r,h,t,i,s:longint; function calc(x:longint):real;
var d,tt:real;k:longint;
begin
if x< then exit(h);
tt:=sqrt(*h/g);
k:=trunc(x/tt);
if (k mod =) then
begin
d:=x-k*tt;
exit(h-g*d*d/);
end
else
begin
d:=k*tt+tt-x;
exit(h-g*d*d/);
end;
end; procedure sort(l,r:longint);
var
i,j:longint;x,y:real;
begin
i:=l;
j:=r;
x:=a[(l+r) div ];
repeat
while a[i]<x do
inc(i);
while x<a[j] do
dec(j);
if not(i>j) then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-;
end;
until i>j;
if l<j then
sort(l,j);
if i<r then
sort(i,r);
end; procedure main;
var i:longint;
begin
readln(n,h,r,t);
for i:= to n- do
a[i]:=calc(t-i);
sort(,n-);
for i:= to n- do
begin
write((a[i]+*r*i/)::,' ');
end;
end; begin
readln(s);
for i:= to s do main;
end.

[POJ3684]Physics Experiment的更多相关文章

  1. POJ3684 Physics Experiment 【物理】

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

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

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

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

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

  4. poj 3684 Physics Experiment 弹性碰撞

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

  5. Physics Experiment(POJ 3684)

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

  6. Physics Experiment 弹性碰撞 [POJ3684]

    题意 有一个竖直的管子内有n个小球,小球的半径为r,最下面的小球距离地面h高度,让小球每隔一秒自由下落一个,小球与地面,小球与小球之间可视为弹性碰撞,让求T时间后这些小球的分布 Input The f ...

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

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

  8. POJ 3684 Physics Experiment

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

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

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

随机推荐

  1. Asp.net 导入Excel数据

    前台代码: <body> <form id="form1" runat="server"> <div> <asp:Fi ...

  2. Markdown语法备忘

    标题 标题 标题是每篇文章都需要也是最常用的格式,在 Markdown 中,如果一段文字被定义为标题,只要在这段文字前加 # 号即可. # 一级标题 ## 二级标题 ### 三级标题 以此类推,总共六 ...

  3. Linux CentOS下shell显示-bash-4.1$ 不显示用户名和主机名的解决方法

    CentOS下新增加一个用户,登录进去会发现shell脚本信息没有显示用户名和主机名,反而显示的是-bash-4.1$,如图所示: 而不是我们经常看到的username@hostname$的组合,看起 ...

  4. VisualStudio自定义代码段_方法二

    1.在项目中新增一个xml文件为vcoo.snippet,然后右键“插入代码段”,选择Snippet即可: 2.修改代码片段内容后保存: 3.VS菜单中选择“工具”-“代码段管理器”导入这个snipp ...

  5. 《javascript高级程序设计》对象图

    1.原型链图 2.作用域链图 3.继承

  6. CSS3实战:让我们尽情的圆角吧

    如果说,WAP2.0网页的机型.浏览器适配给我们无线制作经理造成了巨大的心理 阴影,那么从iPhone.Android这些高端手机应用 起,我们终于可以庆幸比其他同行提 前迎来了一个新时代,这两种高端 ...

  7. [转载]初学C#之list

    C# List<T>用法 所属命名空间:System.Collections.Generic public class List<T> : IList<T>, IC ...

  8. 关于PIL库的一些概念

    关于PIL库的一些概念 pil能处理的图片类型pil可以处理光栅图片(像素数据组成的的块). 通道一个图片可以包含一到多个数据通道,如果这些通道具有相同的维数和深度,Pil允许将这些通道进行叠加 模式 ...

  9. Integer.valueOf与Integer.parseInt的小疑惑

    参考博客: http://www.importnew.com/9162.html 测试代码如下: public class Main { /** * 备注:结果跟你的JDK版本有关系: * * 我的是 ...

  10. QT 的信号与槽机制介绍

    https://www.ibm.com/developerworks/cn/linux/guitoolkit/qt/signal-slot/ http://www.kuqin.com/qtdocume ...