Physics Experiment
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 784   Accepted: 266   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 Hmeters 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

 
方法类似POJ ants 那题。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath> using namespace std; const int MAX = ;
const double g = 10.0;
int N,H,R,T;
double y[MAX]; double cal(int T) {
if(T < ) return H;
double t = sqrt( * H / g);
int k = (int) T / t;
if(k % == ) {
double d = T - k * t;
return H - g * d * d / ;
} else {
double d = k * t + t - T;
return H - g * d * d / ;
}
} void solve() {
for(int i = ; i < N; ++i) {
y[i] = cal(T - i);
} sort(y ,y + N);
for(int i = ; i < N; ++i) {
printf("%.2f%c",y[i] + * R * i / 100.0,i + == N ? '\n' : ' ');
}
}
int main()
{
int C;
//freopen("sw.in","r",stdin);
scanf("%d",&C);
while(C--) {
scanf("%d%d%d%d",&N,&H,&R,&T); solve();
}
// cout << "Hello world!" << endl;
return ;
}

poj 3684的更多相关文章

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

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

  2. poj 3684 Physics Experiment 弹性碰撞

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

  3. Physics Experiment(POJ 3684)

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

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

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

  5. POJ 3684 Priest John&#39;s Busiest Day 2-SAT+输出路径

    强连通算法推断是否满足2-sat,然后反向建图,拓扑排序+染色. 一种选择是从 起点開始,还有一种是终点-持续时间那个点 開始. 若2个婚礼的某2种时间线段相交,则有矛盾,建边. easy出错的地方就 ...

  6. POJ 3684 Physics Experiment

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

  7. 弹性碰撞 poj 3684

    Simon is doing a physics experiment with N identical balls with the same radius of R centimeters. Be ...

  8. ProgrammingContestChallengeBook

    POJ 1852 Ants POJ 2386 Lake Counting POJ 1979 Red and Black AOJ 0118 Property Distribution AOJ 0333 ...

  9. poj 1852&3684 题解

    poj 1852 3684 这两题思路相似就放在一起. 1852 题意 一块长为L长度单位的板子(从0开始)上有很多只蚂蚁,给出它们的位置,它们的方向不确定,速度为每秒一长度单位,当两只蚂蚁相遇的时候 ...

随机推荐

  1. wpf做的可扩展记事本

    记得有个winform利用反射做的可扩展笔记本,闲来无事,便用wpf也搞了个可扩展记事本,可用接口动态扩展功能,较简单,以便参考: 目录结构如下: MainWindow.xaml为主功能界面,Func ...

  2. wpf mvvm MenuItem的Command事件

    这是一个事件的辅助类,可以通过它实现MenuItem的Command事件 public class MyCommands : Freezable, ICommand, ICommandSource { ...

  3. MIFARE系列8《D8M1.exe》

    软件名:D8M1.exe 更新时间:2014.06.28 操作系统:windowAll 外部设备:D8读卡器 D8M1可以对MIFARE块读写操作,支持1K,4K.检验KEY后返回SAK,QTAQ,U ...

  4. qtp 设置等待时间

    1.file->settings->run .默认的时间是20 秒 2. browser("browser").Navigate http://www.baidu.co ...

  5. 【HTML5】炫丽的时钟效果Canvas绘图与动画基础练习

    源自慕课网 效果如下: 全部代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ...

  6. C++设计模式——享元模式

    本文版权归果冻说所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利.如果这篇文章对你有帮助,你可以请我喝杯咖啡. » 本文链接:http:// ...

  7. nodejs tools

    1.supervisor npm install supervisor -g supervisor app.js cd public cd bin supervisor www http://www. ...

  8. 搭建SpringMVC+MyBatis开发框架五

    建立web结构 1.在webapp目录下新建css.img和js文件夹,删除默认的index.jsp文件:  2.在WEB-INF文件夹下建立一个page文件夹,然后在page下新建一个index. ...

  9. window窗口-button(按钮)-dialog(对话框,带按钮)

    描述:一个可拖动的窗口程序,默认情况下窗口自由移动.调整大小.打开关闭! 案例1(普通的窗口): <div class="easyui-window" icon-Cls=&q ...

  10. C#制作高仿360安全卫士窗体(四)- 水晶按钮

    项目越来越紧,我也乐此不疲.自从上次C#制作高仿360安全卫士窗体(三)出来之后,就开始有一些人在说为什么还在坚持写这么落后的东西.我想说的是,我是从事企业信息化工作的,所有程序都只对内部使用.所以只 ...