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

2
1 10 10 100
2 10 10 100

Sample Output

4.95
4.95 10.20 题意 : 每隔一秒会释放一个小球,问最终所有小球底端距离地面的位置高度。
思路 :
  1 . 由于是发生弹性碰撞,即小球发生碰撞后,速度反向,大小不变,因此当两个小球发生
  2 .先考虑 小球的半径为 0 的时候,即所有的小球都从同一点释放出去,只是时间不同,计算出所有小球的高度,排序后即为所求
  3 . 若有半径,上面的求一定比最下面的球多 2*r*i 的重力势能,因此只需要再加上此高度即可
  
推荐博客 :http://www.cnblogs.com/smilesundream/p/5134406.html 代码 :
int n, h, r, t;
double arr[105]; double cal(int t){
if (t < 0) return 1.0*h;
double t1 = sqrt(2.0*h/10.0);
int k = t / t1;
if (k & 1){
return 1.0*h - 5.0*((k+1)*t1 - t)*((k+1)*t1 - t);
}
else {
return 1.0*h - 5.0*(t - k*t1)*(t - k*t1);
}
} int main() {
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", sttout);
int T; cin >> T;
while(T--){
scanf("%d%d%d%d", &n, &h, &r, &t);
for(int i = 0; i < n; i++){
arr[i] = cal(t - i);
}
sort(arr, arr+n);
for(int i = 0; i < n; i++){
printf("%.2lf", arr[i]+2.0*r*i/100.0);
printf("%c", i+1 == n?'\n':' ');
}
} return 0;
}

最新文章

  1. Creating a SharePoint Sequential Workflow
  2. java 从数据删除指定值
  3. ZYNQ学习之二-EMIO
  4. Javascript的匿名函数与自执行
  5. Android Mvc 实现
  6. nosql(1)---radis
  7. [linux basic 基础]----线程的属性
  8. android handler机制和Timer采用
  9. 理解ios 11中webview的视口
  10. 衣带渐宽终不悔,为伊消得人憔悴--DbHelper增强版
  11. Spring的断言工具类Assert的基本使用
  12. HTTP/1.1 chunked 解码
  13. fopen() 返回 NULL, 奇葩原因:当前进程打开多个句柄,忘记关闭。(bug)
  14. Windows 系统判断MD5 值的办法
  15. Could not transfer artifact org.springframework
  16. CefSharp 封装自己的简单H5浏览器 详细配置
  17. 17秋 SDN课程 第二次上机作业
  18. vue 双向数据绑定 Vue事件介绍 以及Vue中的ref获取dom节点
  19. loli的搜索测试-5
  20. 淘宝店铺模板开发SDK2.0下载安装图文教程

热门文章

  1. 基于 Laravel-Admin 在十分钟内搭建起功能齐全的后台模板
  2. H3C IPv6地址自动配置
  3. 多校 HDU - 6614 AND Minimum Spanning Tree (二进制)
  4. activiti工作流引擎学习(三)
  5. Linux 内核class_simple 接口
  6. es6笔记 day3---数组新增东西
  7. msbuild 项目文件常用判断条件
  8. POJ1741 点分治模板
  9. Android studio 使用git仓库记录
  10. 使用原生JDBC方式对数据库进行操作