题意

有一个竖直的管子内有n个小球,小球的半径为r,最下面的小球距离地面h高度,让小球每隔一秒自由下落一个,小球与地面,小球与小球之间可视为弹性碰撞,让求T时间后这些小球的分布

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


1 10 10 100 
2 10 10 100 
Sample Output

4.95 
4.95 10.20

Analysis

首先这种弹性碰撞的题可以很快联想到两只蚂蚁擦肩而过的题,但是这是有半径的,是与之前视为质点的情况是不同的,如何处理?

我们根据弹性碰撞,有动量守恒和机械能守恒,得到1,2两个求撞后的速度分别为

V1'=2*(m1-m2)/(m1+m2)*V1+2*m2/(m1+m2)*V2

V2'=2*(m2-m1)/(m1+m2)*V2+2*m1/(m1+m2)*V1

那也就是1,2两个小球发生了速度交换。

我们不妨设1为下面的求,2为上面的球,那么碰撞后(相互穿越),1的重力势能瞬间增加2mgr,速度不变,2的重力势能瞬间减少2mgr,速度也不变

所以我们可以把他等效于就相当于没有半径的情况+某球下面的球的数量×2r

对于计算位置,我们由H=1/2gt2可得,t=√(2H/g)

我们令k是满足kt<=T的最大正整数,那么

ansH=    H-1/2g(T-kt)2 (k&2==0)

    H-1/2g((k+1)t-T)2 (k&2==1)

Code

 #include<cstdio>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include<map>
#include <algorithm>
#include <set>
using namespace std;
#define MM(a) memset(a,0,sizeof(a))
typedef long long LL;
typedef unsigned long long ULL;
const int mod = ;
const double eps = 1e-;
const int inf = 0x3f3f3f3f;
const double g=;
int cas,n,h,r,t,k;
double t0,tx,a[],temp;
double solve(int x)
{
if(x<) return h;
t0=sqrt(*h*1.0/g);
k=int(x/t0);
if(k%==) temp=x-k*t0;
else temp=t0-(x-k*t0);
return h-0.5*g*temp*temp;
}
int main()
{
cin>>cas;
while(cas--)
{
scanf("%d %d %d %d",&n,&h,&r,&t);
for(int i=;i<=n;i++)
a[i]=solve(t-(i-));
sort(a+,a+n+);
for(int i=;i<=n;i++)
printf("%.2f%c",a[i]+*(i-)*r/100.0,i==n?'\n':' ');//注意%s输出字符串,%c输出字符,所以这个地方不能用“”
}  //因为%c无法输出“”字符串
return ;
}

Physics Experiment 弹性碰撞 [POJ3684]的更多相关文章

  1. poj 3684 Physics Experiment 弹性碰撞

    Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1489   Accepted: 509 ...

  2. Greedy:Physics Experiment(弹性碰撞模型)(POJ 3848)

    物理实验 题目大意:有一个与地面垂直的管子,管口与地面相距H,管子里面有很多弹性球,从t=0时,第一个球从管口求开始下落,然后每1s就会又有球从球当前位置开始下落,球碰到地面原速返回,球与球之间相碰会 ...

  3. POJ 3684 Physics Experiment(弹性碰撞)

    Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2936   Accepted: 104 ...

  4. POJ3684 Physics Experiment 【物理】

    Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1031   Accepted: 365 ...

  5. [POJ3684]Physics Experiment

      Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1363   Accepted: 476   Special Judge ...

  6. poj 3684 Physics Experiment(数学,物理)

    Description Simon ), the first ball is released and falls down due to the gravity. After that, the b ...

  7. POJ:3684-Physics Experiment(弹性碰撞)

    Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3392 Accepted: 1177 Sp ...

  8. Physics Experiment(POJ 3684)

    原题如下: Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3583   Accepte ...

  9. POJ 3684 Physics Experiment

    和蚂蚁问题类似. #include<cstdio> #include<cstring> #include<cmath> #include<vector> ...

随机推荐

  1. Python操作文件-20181121

    Python操作文件 Python操作文件和其他语言一样,操作的过程无非是先定位找到文件.打开文件,然后对文件进行操作,操作完成后关闭文件即可. 文件操作方式:对文件进行操作,主要就是读.写的方式,p ...

  2. python中的装饰器迭代器生成器

    装饰器: 定义:本质是函数(装饰其它函数) 为其它函数添加附加功能 原则: 1 不能修改被装饰函数源代码    2 不修改被装饰函数调用方式 实现装饰器知识储备: 1 函数即‘’变量‘’ 2 高阶函数 ...

  3. 结合别人的文章,做RocketMQ的一点原理分析,结合源码(尽量)----未完待续

    Broker 与Namesrv的关系 1.从namesrv获取配置信息 /** * BrokerConfig类 * * broker每隔30秒(此时间无法更改)向所有nameserver发送心跳,心跳 ...

  4. 使用InternalsVisibleTo给assembly添加“友元assembly”

    C#的internal关键字可以使标记的方法,字段或者属性等等只能在当前assembly内部使用,那么如果其他的assembly需要使用这个internal的方法的时候怎么办呢?.NET提供了一种类似 ...

  5. 第十一节: EF的三种模式(一) 之 DBFirst模式(SQLServer和MySQL两套方案)

    一. 简介 EF连接数据库有三种模式,分别是DBFirst.ModelFirst.CodeFirst,分别适用于不同的开发场景. 该章节,将主要介绍EF的DBFirst连接SQLServer数据库和M ...

  6. html css hover也会冒泡

    <HEAD> <style type="text/css"> div:hover { color:blue !important; } </style ...

  7. [译]Ocelot - Request Aggregation

    原文 Aggregate ReRoutes用来组合多个ReRoutes,将它们的响应结果映射到一个响应中返回给客户端. 为了使用Aggregate ReRoutes,你必须像下面的ocelot.jso ...

  8. for 循环 与forEach 里面return 的区别

    for 循环里面 return 可以直接终止 跳出 循环 forEach 是中断本次循环 直接 下一个循环 forEach想要取到值之后 直接跳出循环 可以用 try catch let arr = ...

  9. 在window系统上安装redis服务-Invalid argument during startup: Failed to open the .conf

    当前redis版本: redis-cli -v redis-cli 3.0.503 网上给的命令(在redis所在文件夹下执行): redis-server –service-install redi ...

  10. Mysql --数据库概述1

    什么是数据(Data)? 描述事物的符号记录称为数据,描述事物的符号既可以是数字,也可以是文字.图片,图像.声音.语言等,数据由多种表现形式,它们都可以经过数字化后存入计算机 在计算机中描述一个事物, ...