poj3684(相遇碰撞模型)
来源:互联网 发布:程序员html5表白网页 编辑:程序博客网 时间:2024/06/05 11:24
/*translation:将N个半径为R的球放入一个圆桶(圆桶口径刚好放入一个球),将圆桶竖直放着,最下端距离地面H高度,让球每隔一秒自由下落,求T时刻各个球距离地面的高度。solution:所有的球都一样可以忽视它们的碰撞,视为互相穿过继续运动。这样就可以分别单独求出每个球T时刻的高度后排序就是答案了。note:注意在开始处理的时候要将所有的球按照高度与地一个小球一样的高度来处理。在输出的时候再加上实际的距离。date:2016.11.10*/#include <iostream>#include <cstdio>#include <cstring>#include <vector>#include <algorithm>#include <cmath>using namespace std;const int maxn = 10000 + 5;int n, h, r, t;vector<double> ans;double compute(double current_h, double current_t){if(current_t < 0)return current_h;double fall_t = sqrt(2.0 * current_h / 10.0);int k = (int)(current_t / fall_t);double time;if(k & 1){time = k*fall_t + fall_t - current_t;}else{time = current_t - k*fall_t;}return current_h - 5.0 * time * time;}int main(){//freopen("in.txt", "r", stdin); int T; scanf("%d", &T); while(T--){scanf("%d%d%d%d", &n, &h, &r, &t);ans.clear();double th;for(int i = 0; i < n; i++){th = compute((double)h, (double)t - i);ans.push_back(th);}sort(ans.begin(), ans.end());for(int i = 0; i < n; i++){printf("%.2f%c", ans[i] + 2*r*i/100.0, i + 1 == n ? '\n' : ' ');} } return 0;}
0 0
- poj3684(相遇碰撞模型)
- POJ3684 弹性碰撞
- POJ3684-Physices Experiment【弹性碰撞】
- poj3684
- poj3684 Physics Experiment(加解析)
- 《挑战程序设计竞赛》3.2.3 常用技巧-弹性碰撞 POJ3684 2674
- OpenGL碰撞检测模型
- Unity 模型碰撞
- 相遇(转载)
- 相遇
- 相遇
- 相遇
- 相遇
- 相遇
- 相遇
- 相遇
- 相遇
- 相遇
- 事务
- Android Studio 中手把手教你设置switch/case代码块自动补齐
- 原子性、内存可见性和重排序——重新认识synchronized和volatile
- 软考(五)-考后总结
- Python练习之——肿瘤预测
- poj3684(相遇碰撞模型)
- C语言的基本数据类型与表达式
- 小小收获
- 多行字符串
- Vim
- 函数和面对对象
- 我的第一篇博客——About Spring In Action
- 二分查找算法的简单实现
- DataProject Winform开源框架 cs版 架构自动更新 更新包制作