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. H3C 用三层交换机实现VLAN间路由

  2. 分析JVM动态生成的类

    总结思考:让jvm创建动态类及其实例对象,需要给它提供哪些信息? 三个方面: 1.生成的类中有哪些方法,通过让其实现哪些接口的方式进行告知: 2.产生的类字节码必须有个一个关联的类加载器对象: 3.生 ...

  3. MySQL Workbench: mysqldump version mismatch

    Windows10 64bit系统下,步骤就是: Edit --> preferences --> Administrator --> Path to mysqldump tool: ...

  4. Echarts构建图表

    Echarts学习-构建图表 相信有很多的前端开发人员在开发Echarts图表的过程中都遇到对图表结构过无从下手,面对一大堆的专业词汇一脸懵逼的样子,在经过了一段时间的踩坑后,终于摸索出了一套完善的学 ...

  5. 性能测试基础-SOCKET协议用例

    1.首先在进行性能测试的时候,我们要了解软件的通信协议是什么,我们使用什么协议,如何去模拟.SOCKET协议主要应用于在C/S模式的系统. 作者本人已当初做过的C/S架构的系统做的脚本录制,在上面做脚 ...

  6. 初识Maven POM

    POM Project Object Model项目对象模型定义了项目的基本信息,用于描述项目如何构建,申明项目依赖,等等. pom元素: <modelVersion>4.0.0</ ...

  7. Java 学习笔记(7)——接口与多态

    上一篇说了Java面向对象中的继承关系,在继承中说到:调用对象中的成员变量时,根据引用类型来决定调用谁,而调用成员方法时由于多态的存在,具体调用谁的方法需要根据new出来的对象决定,这篇主要描述的是J ...

  8. 【Linux】ssh-copy-id三步实现ssh免密登陆

    一.本地机器上使用ssh-keygen产生公钥私钥对 ssh-keygen -t rsa -C "XXXX@163.com" --->执行完会在~/.ssh/下生成公钥私钥对 ...

  9. Excel读取方式优化(浅谈对规律的认知)

    相信大家都接触过对Excel的读取,今天突发奇想,想将自己的一小段经历分享出来.灵活识别列名并将其存到对象数组中. 固定形式的Excel列的读取: 源于我第一次操作Excel,将列名对应成table中 ...

  10. Netty堆外内存泄漏排查,这一篇全讲清楚了

    上篇文章介绍了Netty内存模型原理,由于Netty在使用不当会导致堆外内存泄漏,网上关于这方面的资料比较少,所以写下这篇文章,专门介绍排查Netty堆外内存相关的知识点,诊断工具,以及排查思路提供参 ...