Physics Experiment
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 784   Accepted: 266   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 Hmeters 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 NHRT.
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

 
方法类似POJ ants 那题。

#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 / ;
}
} void solve() {
for(int i = ; i < N; ++i) {
y[i] = cal(T - i);
} sort(y ,y + N);
for(int i = ; i < N; ++i) {
printf("%.2f%c",y[i] + * R * i / 100.0,i + == N ? '\n' : ' ');
}
}
int main()
{
int C;
//freopen("sw.in","r",stdin);
scanf("%d",&C);
while(C--) {
scanf("%d%d%d%d",&N,&H,&R,&T); solve();
}
// cout << "Hello world!" << endl;
return ;
}

poj 3684的更多相关文章

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

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

  2. poj 3684 Physics Experiment 弹性碰撞

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

  3. Physics Experiment(POJ 3684)

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

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

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

  5. POJ 3684 Priest John&#39;s Busiest Day 2-SAT+输出路径

    强连通算法推断是否满足2-sat,然后反向建图,拓扑排序+染色. 一种选择是从 起点開始,还有一种是终点-持续时间那个点 開始. 若2个婚礼的某2种时间线段相交,则有矛盾,建边. easy出错的地方就 ...

  6. POJ 3684 Physics Experiment

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

  7. 弹性碰撞 poj 3684

    Simon is doing a physics experiment with N identical balls with the same radius of R centimeters. Be ...

  8. ProgrammingContestChallengeBook

    POJ 1852 Ants POJ 2386 Lake Counting POJ 1979 Red and Black AOJ 0118 Property Distribution AOJ 0333 ...

  9. poj 1852&3684 题解

    poj 1852 3684 这两题思路相似就放在一起. 1852 题意 一块长为L长度单位的板子(从0开始)上有很多只蚂蚁,给出它们的位置,它们的方向不确定,速度为每秒一长度单位,当两只蚂蚁相遇的时候 ...

随机推荐

  1. instanceof、==号、Objetc类

    1)instanceof: 判断某个对象是否为某个类的实例,注意多态的运用,一个父类引用指向子类的对象,根据继承,子类就是父类,所以子类也可以看做是父类的一个实例.  形式:引用 instanceof ...

  2. 【转】C# 子窗体如何调用父窗体的方法

    网络上有几种方法,先总结如下: 调用窗体(父):FormFather,被调用窗体(子):FormSub. 方法1: 所有权法       //FormFather:        //需要有一个公共的 ...

  3. Sql Server数据的加密与解密

    Sql Server数据的加密与解密 在sql server中,我们如何为数据进行加密与解密,避免使用者窃取机密数据? 对于一些敏感数据,如密码.卡号,一般不能使用正常数值来存储.否则会有安全隐患.以 ...

  4. SQL Server基础

    一.常用命令 1.使用命令行开启SQL Server服务 获取管理员权限的命令行工具: net start mssqlserver 开启sql server服务 net restart mssqlse ...

  5. 安装Oracle11g时,检测到系统的主 IP 地址是 DHCP 分配的地址

    检查完成.此次检查的总体结果为: 失败 <<<< 问题: 安装检测到系统的主 IP 地址是 DHCP 分配的地址. 建议案: Oracle 支持在具有 DHCP 分配的 IP ...

  6. android获取手机录

    在Android开发中,读取手机通讯录中的号码是一种基本操作,但是由于Android的版本众多,所以手机通讯录操作的代码比较纷杂,在本文中进行一下总结. Android1.5是现在的Android系统 ...

  7. Eclipse基金会

    昨天Eclipse基金会庆祝其成立十周年.2004年2月的新闻稿宣布该非盈利组织的正式成立,由包括开发者.消费者和插件提供商在内的各独立团体组成的董事会,为Eclipse的长期发展负责. 基金会成立时 ...

  8. django-pagination的使用

    1.安装django-pagination 2.将文件夹pagination复制到项目的根目录下 3.修改settings: 1.将 'pagination.middleware.Pagination ...

  9. scrapy 错误

    1. 安装win32时候 Unable to find vcvarsall.bat 解决方法: 1.如果你没有安装vc,去微软下个 VS2008 的免费版就能解决此问题. 2.如果你安装的是VS201 ...

  10. [shell基础]——sort命令

    sort命令 sort是按照ASCII码升序输出,且是从首字符依次向后比较的 常见选项      -c 测试文件是否已经被排序 -r  逆向排序      -n 按照数字数值大小排序 -t  指定分割 ...