弹性碰撞 poj 3684
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的更多相关文章
- POJ 3684 Physics Experiment(弹性碰撞)
Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2936 Accepted: 104 ...
- poj 3684 Physics Experiment 弹性碰撞
Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1489 Accepted: 509 ...
- poj 3684
Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 784 Accepted: 266 ...
- Physics Experiment(POJ 3684)
原题如下: Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3583 Accepte ...
- poj 3684 Physics Experiment(数学,物理)
Description Simon ), the first ball is released and falls down due to the gravity. After that, the b ...
- POJ 3684 Priest John's Busiest Day 2-SAT+输出路径
强连通算法推断是否满足2-sat,然后反向建图,拓扑排序+染色. 一种选择是从 起点開始,还有一种是终点-持续时间那个点 開始. 若2个婚礼的某2种时间线段相交,则有矛盾,建边. easy出错的地方就 ...
- POJ 3684 Physics Experiment
和蚂蚁问题类似. #include<cstdio> #include<cstring> #include<cmath> #include<vector> ...
- ProgrammingContestChallengeBook
POJ 1852 Ants POJ 2386 Lake Counting POJ 1979 Red and Black AOJ 0118 Property Distribution AOJ 0333 ...
- poj 1852&3684 题解
poj 1852 3684 这两题思路相似就放在一起. 1852 题意 一块长为L长度单位的板子(从0开始)上有很多只蚂蚁,给出它们的位置,它们的方向不确定,速度为每秒一长度单位,当两只蚂蚁相遇的时候 ...
随机推荐
- H3C 基本ACL
- linux 原子变量
有时, 一个共享资源是一个简单的整数值. 假设你的驱动维护一个共享变量 n_op, 它告 知有多少设备操作目前未完成. 正常地, 即便一个简单的操作例如: n_op++; 可能需要加锁. 某些处理器可 ...
- JS的防抖与节流学习笔记
防抖(debounce):当持续触发事件时,在一定的时间段内,只有最后一次触发的事件才会执行. 例: function debounce(fn, wait) { var timer = null; r ...
- Java中try catch finally执行
直接上代码实例: public static void main(String[] args) { System.out.println(test1()); } static int test1 ...
- 2019-8-31-How-to-fix-nuget-Unrecognized-license-type-MIT-when-pack
title author date CreateTime categories How to fix nuget Unrecognized license type MIT when pack lin ...
- JavaScript实现版本号比较
/* * JavaScript实现版本号比较 * 传入两个字符串,当前版本号:curV:比较版本号:reqV * 调用方法举例:Version('5.12.3','5.12.2'),将返回true * ...
- 对“TD信息树”的使用体验
在本次同2017级学长进行的软件交流会上,我们有幸使用学长们开发的软件与成果,进过27个不尽相同的软件的使用,让我初步意识到了学习软件工程这门学科的实用价值.最终我选择了"TD信息树&quo ...
- cglib的使用
前言 最近一直在看Spring源码,其实我之前一直知道AOP的基本实现原理: 如果针对接口做代理默认使用的是JDK自带的Proxy+InvocationHandler 如果针对类做代理使用的是Cgli ...
- axure公式的使用和局部变量简介
什么时候有公式?当前面是值的时候后面都可以用公式 公式怎么用?1.公式里直接写入字符串 2.变量([变量])加上字符串 3.[[]]里面运算 外面字符串 两个中括号里的变量就可以计算或者显示默认值而不 ...
- DEVOPS技术实践_07:Jenkins 管道工作
一 简介 由于在公司构建很多工作,都是使用的maven工作构建的,这种构建方式很大缺点就是所有的工作都需要一步一步的配置,当项目较多,需求变动时,需要很大的精力去修改配置,很费劲 Pipeline即为 ...