Physics Experiment(POJ 3684)
- 原题如下:
Physics Experiment
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3583 Accepted: 1275 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 ≤ 10000Output
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 100Sample Output
4.95
4.95 10.20 - 题解:一个球的情形很简单。多个球的情形先考虑R=0,模仿热身题(POJ 1852),在那道题中两只蚂蚁相遇后折返我们将其看作不折返而是擦身而过继续走下去,这里我们就可以无视碰撞,视为直接互相穿过继续运动,由于在有碰撞时,球的相对顺序是不会变得的,所以忽略碰撞,将计算得到的坐标进行排序后,就能直到每个球的最终位置。然后我们再考虑R>0的情形,对于从下方开始的第i个球,在按照R=0计算的结果上加上2Ri就好了。
- 代码:
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <cstring>
#define number s-'0' using namespace std; const int MAX_N=;
const double g=10.0;
int K,N,H,R,T;
double y[MAX_N]; void read(int &x){
char s;
x=;
bool flag=;
while(!isdigit(s=getchar()))
(s=='-')&&(flag=true);
for(x=number;isdigit(s=getchar());x=x*+number);
(flag)&&(x=-x);
} void write(int x)
{
if(x<)
{
putchar('-');
x=-x;
}
if(x>)
write(x/);
putchar(x%+'');
} double calc(int); int main()
{
read(K);
while (K>)
{
read(N);read(H);read(R);read(T);
for (int i=; i<N; i++)
{
y[i]=calc(T-i);
}
sort(y,y+N);
for (int i=; i<N; i++)
printf("%.2f%c", y[i]+*R*i/100.0, i+==N? '\n': ' ');
K--;
}
} double calc(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/;
}
}
Physics Experiment(POJ 3684)的更多相关文章
- POJ 3684 Physics Experiment(弹性碰撞)
Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2936 Accepted: 104 ...
- 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 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 784 Accepted: 266 ...
- [POJ3684]Physics Experiment
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1363 Accepted: 476 Special Judge ...
- POJ3684 Physics Experiment 【物理】
Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1031 Accepted: 365 ...
- 弹性碰撞 poj 3684
Simon is doing a physics experiment with N identical balls with the same radius of R centimeters. Be ...
- POJ 3684 Physics Experiment
和蚂蚁问题类似. #include<cstdio> #include<cstring> #include<cmath> #include<vector> ...
- Greedy:Physics Experiment(弹性碰撞模型)(POJ 3848)
物理实验 题目大意:有一个与地面垂直的管子,管口与地面相距H,管子里面有很多弹性球,从t=0时,第一个球从管口求开始下落,然后每1s就会又有球从球当前位置开始下落,球碰到地面原速返回,球与球之间相碰会 ...
随机推荐
- 一文看懂 Netty 架构设计
本文重点分析 Netty 的逻辑架构及关键的架构质量属性,希望有助于大家从 Netty 的架构设计中汲取营养,设计出高性能.高可靠性和可扩展的程序. Netty 的三层架构设计 Netty 采用了典型 ...
- [noip2002] 产生数
题目描述 给出一个整数 n (n<1030)和 k 个变换规则 (k < 15) . 规则: 一位数可变换成另一个一位数: 规则的右部不能为零. 例如:n = 234 .有规则( k=2 ...
- three.js UV映射简述
今天郭先生来说一说uv映射,什么是uv映射?uv映射就是将二维的贴图映射到对象的一个面(或者多个面)上.说到这个问题,我们就不得不了解一下Geometry的点.面和uv的结构.我们以BoxGeomet ...
- 《Java从入门到失业》第二章:Java环境(一):Java SE安装
从这一章开始,终于我们可以开始正式进入Java世界了.前面我们提到过,Java分三个版本,我们这里只讨论Java SE. 2.1Java SE安装 所谓工欲善其事,必先利其器.第一步,我们当然是要下载 ...
- Markdown实验样例
一级标题 二级标题 三级标题 重新开始一个段落 这是新的段落 斜体文本 粗体文本 粗斜体文本 下面是分隔线 删除线 下划线 脚注[1] 无序列表 第一项 嵌套元素1 嵌套元素2 第二项 嵌套元素1 嵌 ...
- Promise 方法
functionB(){ this.functionA() } functionA(){ return new Promise((resolve, reject) => { this.$http ...
- 斗地主小游戏随机发牌PHP代码
<?php header("Content-Type:text/html;charset=UTF-8"); $num=['A','2','3','4','5','6','7' ...
- 牛客网PAT练兵场-A除B
题目地址:https://www.nowcoder.com/pat/6/problem/4043 题解:遍历大数,边除边输出,最后得到余数输出即可 /** * *作者:Ycute *时间:2019-1 ...
- codeforce Round #599(Div.2)
题目传送门 A. Maximum Square 题目意思是给你n个长条,每个长条的高度是num[i](0 < i < n),每一条的宽度都是 1 :然后求这些长条可以组成的最大面积的正方形 ...
- java23种设计模式——四、原型模式
源码在我的github和gitee中获取 目录 java23种设计模式-- 一.设计模式介绍 java23种设计模式-- 二.单例模式 java23种设计模式--三.工厂模式 java23种设计模式- ...