POJ 3684 Physics Experiment(弹性碰撞)
Time Limit: 1000MS | Memory Limit: 65536K | |||
Total Submissions: 2936 | Accepted: 1045 | Special Judge |
Description
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
Source
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath> using namespace std; const int MAX = ;
const double g = 10.0;
int N,H,R,T;
double y[MAX]; double cal(int T)
{
if(T < ) return H;
double t = sqrt( * H / g);
int k = (int) T / t;
if(k % == )
{
double d = T - k * t;
return H - g * d * d / ;
}
else
{
double d = k * t + t - T;
return H - g * d * d / ;
}
} int main()
{
int C;
scanf("%d",&C);
while(C--)
{
scanf("%d%d%d%d",&N,&H,&R,&T);
for(int i = ; i <N; i++)
{
y[i] = cal(T - i);
}
sort(y ,y + N);
for(int i = ; i <N;i++)
{
printf("%.2f",y[i] + * R * (i) / 100.0);
if (i ==N-) cout << "\n";
else cout << " ";
}
}
return ;
}
POJ 3684 Physics Experiment(弹性碰撞)的更多相关文章
- poj 3684 Physics Experiment 弹性碰撞
Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1489 Accepted: 509 ...
- poj 3684 Physics Experiment(数学,物理)
Description Simon ), the first ball is released and falls down due to the gravity. After that, the b ...
- POJ 3684 Physics Experiment
和蚂蚁问题类似. #include<cstdio> #include<cstring> #include<cmath> #include<vector> ...
- POJ:3684-Physics Experiment(弹性碰撞)
Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3392 Accepted: 1177 Sp ...
- Greedy:Physics Experiment(弹性碰撞模型)(POJ 3848)
物理实验 题目大意:有一个与地面垂直的管子,管口与地面相距H,管子里面有很多弹性球,从t=0时,第一个球从管口求开始下落,然后每1s就会又有球从球当前位置开始下落,球碰到地面原速返回,球与球之间相碰会 ...
- Physics Experiment 弹性碰撞 [POJ3684]
题意 有一个竖直的管子内有n个小球,小球的半径为r,最下面的小球距离地面h高度,让小球每隔一秒自由下落一个,小球与地面,小球与小球之间可视为弹性碰撞,让求T时间后这些小球的分布 Input The f ...
- Physics Experiment(POJ 3684)
原题如下: Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3583 Accepte ...
- 弹性碰撞 poj 3684
Simon is doing a physics experiment with N identical balls with the same radius of R centimeters. Be ...
- poj 3684
Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 784 Accepted: 266 ...
随机推荐
- Mysql 建表时报错 invalid ON UPDATE clause for 'create_date' column
这个错误是由于mysql 版本问题导致的 `create_date` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间', ...
- 解决chrome报Not allowed to load local resource错误的方法
最近项目中遇到了关于图片的更改->保存->本地读取 在本地读取的环节上面出现了错误,一开始用的是直接本地路径,但是在页面上调试的出现了下面的错误,他的路径还是相对路径,下图所示: Goog ...
- MoreEffectiveC++Item35(异常)(条款9-15)
条款9 使用析构函数防止内存泄漏 条款10 在构造函数中防止内存泄漏 条款11 禁止异常信息传递到析构函数外 条款12 理解"抛出一个异常''与"传递一个参数"或调用一个 ...
- Android Studio 问题锦集【持续更新】
想必,大家在使用Android Studio(后面简称AS)的过程中会遇到各种各样的问题,现在,我也来谈谈我在使用AS过程中遇到的错误. 1.Plugin with id 'com.android.a ...
- 下拉列表框DropDownList绑定Dictionary泛型类
DropDownList绑定Dictionary泛型类 定义一个Dictionary泛型类 /// <summary> /// 产品类型 /// </summary> ...
- 微信小程序的一些数据调用方式
1.模板数据的调用 一张图了解一下在wxml页调用预先定义好的模板: 可以看到上面调用了两个模板,数据调用却是不同的,obj是一个对象,对象内包含多个键值对形式的数据: tabbar是一个一维数组,每 ...
- 脚本操作zk
使用[root@localhost bin]# ./zkCli.sh连接本地zk 创建 create [-s] [-e] path data acl 其中,-s是创建顺序或临时结点.默认情况下,不添加 ...
- vue中如何引入全局样式或方法
vue中我么会经常用到通用的一些全局的方法,如何左才能实现全局的复用减少代码累赘呢? 我们一般将公用的方法分装再utils.js文件中,然后再main.js主入口文件中将utils.js中的公共的方法 ...
- 【剑指offer-21】调整数组顺序使奇数位于偶数前面,C++实现(冒泡排序)
1.题目 输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于位于数组的后半部分. 2.思路 本题有两种解法,一种是不保证数组稳定性的解法,一种是保 ...
- windows客户端远程访问linux下mysql方法
windows客户端远程访问linux下mysql方法 1. 改表法.可能是你的帐号不允许从远程登陆,只能在localhost.这个时候只要在localhost的那台电脑,登入mysql后,更改 &q ...