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.

最新文章

  1. CSS垂直居中总结
  2. 在list_*页面显示出一级栏目下的所有二级栏目
  3. JQUERY相关
  4. 【初级】linux cp 命令详解及使用方法实战
  5. jQuery事件流的顺序
  6. Python类
  7. Codeforces Round #382 (Div. 2)B. Urbanization 贪心
  8. packinfo-java的作用
  9. iOS 细节 问题
  10. JAVA学习:方法
  11. hello nodejs
  12. c++面试题【转】
  13. 晓莲说-何不原创:如何通过jad把class批量反编译成java文件
  14. centos7下安装docker(18.2docker日志---ELK)
  15. 【Thymeleaf】浅谈Java模板引擎(带更新...)
  16. monit配置文件
  17. Python初学者随笔Week1
  18. C#中执行Dos命令
  19. Apache安装完后加入系统服务的相关操作详解
  20. Spring整合junit测试

热门文章

  1. httpd.ini
  2. hdu 2594 Simpsons’ Hidden Talents KMP应用
  3. C语言数据结构之栈:括号匹配
  4. uvision4 ide已停止工作
  5. Python 知识点
  6. DB天气app冲刺第二天
  7. Dynamic Programming (DP) 问题总结
  8. Matlab心得及学习方法(不断更新)
  9. 百度地图API使用介绍
  10. 同步两台linux服务器时间同步方案