您的位置:首页 > 其它

POJ 3684 Physics Experiment (弹性碰撞)

2018-02-10 15:54 399 查看
Physics Experiment
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions:2861 Accepted:1024 Special Judge
DescriptionSimon 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
d806
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.
InputThe 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
OutputFor 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 Input2
1 10 10 100
2 10 10 100Sample Output4.95
4.95 10.20#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
int K;
scanf("%d",&K);
while(K--)
{
int n,h,r,T;
scanf("%d%d%d%d",&n,&h,&r,&T);
double hi[102];
for(int i=0;i<n;i++)
{
if(T==0)
{
hi[i]=1.00*h;
continue;
}
double t=sqrt(2*h*1.00/10);
double t1=T-floor(T/(2*t))*2*t;
if(t1<t) hi[i]=h-0.5*10*t1*t1;
else hi[i]=h-0.5*10*(2*t-t1)*(2*t-t1);
T--;
}
sort(hi,hi+n);
for(int i=0;i<n-1;i++)
printf("%.2lf\n",hi[i]+2*r*i*0.01);
printf("%.2lf\n",hi[n-1]+2*r*(n-1)*0.01);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: