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. java Object类

    常用的共性内容 1,实现任何对象的比较,一般比较同一种对象的比较 Object1.equals(Object obj);等同于Object1 == obj: 只有当两个引用指向同一个对象时方法返回tr ...

  2. JS获得QQ号码的昵称,头像,生日

    这篇文章主要介绍了JS获得QQ号码的昵称,头像,生日的简单实例,有需要的朋友可以参考一下 http://r.qzone.qq.com/cgi-bin/user/cgi_personal_card?ui ...

  3. php查询ip地址来源归属地的脚本

    <?php header('Content-Type:text/html;charset=utf-8'); if($_GET['sub']){ $ip = $_GET['ip']; $msg = ...

  4. about Q&A in installing linux[centos6,7]

    keywords:grub1,grub2,gnome,kde, question describe:install centos7 by U disk,出现问题, 解决办法: install cent ...

  5. Python 中模块间全局变量的使用上的注意

    最近用Python写代码,需要用到模块间的全局变量. 网上四处搜索,发现普遍做法是把全局变量放到一个独立的模块中,使用时,导入此全局变量模块即可. 但是在实际使用过程中发现了些小问题:在使用如下代码导 ...

  6. 在jsp中运用ajax实现同一界面不跳转处理事件

    目前,编写应用程序时有两种基本的选择: 桌面应用程序 Web应用程序 它们有什么区别呢?桌面应用程序一般很快(就在您的计算机上运行,不用等待互联网连接),具有漂亮的用户界面(通常和操作系统有关)和非凡 ...

  7. windows store app promise

    Promise.any ---- 参数是一个promise的数组.any的作用就是 promise 数组中任意一个 promise 执行完毕,就会执行 done内的函数 (function () { ...

  8. C#基础|初探反射

    什么是反射 我们编写的C#代码都可以编译成exe文件或dll文件.暂时先把他们叫做程序集吧,程序集中包含了很多信息.你写了一个类,类中会有字段,有属性,有方法,编译是会把这些信息保存在程序集中,暂时把 ...

  9. LFI & RFI & PHP封装协议之安全问题研究

    目录 . 文件包含的基本概念 . LFI(Local File Include) . RFI(Remote File Include) . PHP中的封装协议(伪协议).PHP的流式文件操作模式所带来 ...

  10. GridView 根据要求显示指定值

    最近在写一个小项目用来练手恢复一下功力的,在Users表中有一个用户字段是状态,我使用"0"表示启用,“1”表示禁用, 存到数据库中, 由于之前有一段时间没写代码了,所以有点生疏了 ...