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

弹性碰撞 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. poj 3684

    Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 784   Accepted: 266 ...

  4. Physics Experiment(POJ 3684)

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

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

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

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

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

  7. POJ 3684 Physics Experiment

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

  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. POI 导入、导出Excel

    POI,全称Apache POI,是Apache软件基金会的开放源码函式库,POI提供API给Java程序对Microsoft Office格式档案读和写的功能.项目地址:Apache POI - t ...

  2. H3C OSPF协议分区域管理

  3. P1055 连通块问题

    题目描述 给出一个n行m列的地图,'.'代表陆地,'W'代表水.现在需要你计算地图中有多少个水块.八个方向可以连通 比如:4*6的地图 ...WWW ...WW. WW.... .....W 中有3个 ...

  4. 关于git命令

    1在自己电脑上生成一个密钥然后给老大,老大在github上设置后,你这台电脑才可以访问他的项目ssh-keygen -t rsa -C <邮件名称> ------->获取秘钥 cat ...

  5. CodeChef Ada Pawns

    最小割 留下最多的点 形如左上或者右上没有点的点一定会留下 对于斜着的关系的两个点不能共存 黑白行染色! 白行的点称为 白点,黑点类似 反着连关系 对于一定会留下的,S到白点,黑点到T,都连inf 不 ...

  6. 关于electron中入口文件main.js一些重要参数(持续更新maybe)

    const {app, BrowserWindow} = require('electron') const path = require('path') let mainWindow functio ...

  7. MFC下获取系统内存和当前进程的内存使用情况

    GlobalMemoryStatusEx来获取系统的内存使用情况 GetProcessMemoryInfo获取某个进程的内存使用情况.和任务管理器看到的是一样的. 具体代码如下: void GetSy ...

  8. python 给三个数字排序,不用sort函数

    # 给三个数字排序# 方法一def sort_d(a,b,c): if a>b: a,b=b,a # print (a,b) if b>c: b,c=c,b if a>b: a,b= ...

  9. scrapy分布式Spider源码分析及实现过程

    分布式框架scrapy_redis实现了一套完整的组件,其中也实现了spider,RedisSpider是在继承原scrapy的Spider的基础上略有改动,初始URL不在从start_urls列表中 ...

  10. jsp中获取页面的相对路径

    1.在jsp页面的上方加上这段java代码 <%//        request.getContextPath() 返回当前页面所在的应用的名字://        request.getSc ...