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就会又有球从球当前位置开始下落,球碰到地面原速返回,球与球之间相碰会 ...
随机推荐
- 悄咪咪提高团队幸福感 & Surprise!
前言 本文的灵感是在几个月以前工作不忙(摸鱼)时想到的,老是自己一个人往前冲冲冲也没啥意思,需要想一点办法,来提高团队的效率,提高团队的幸福感(效率起来了,单位时间内代码写的更多,那不就幸福啦 ),经 ...
- 设计模式详解及Python实现
设计模式及Python实现 设计模式是什么? Christopher Alexander:"每一个模式描述了一个在我们周围不断重复发生的问题,以及该问题的解决方案的核心*.这样你就能一次又一 ...
- GitHub标星120K+的JDK并发编程指南,连续霸榜GitHub终于开源了
前言 在编程行业中,有一个东西是和广大程序员形影不离的,在最一开始接触编程就是配置它的运行环境,然后java / javac,对,这个东西就是jdk 昨天项目刚上线,可以稍微休息一下了,但是猛的闲下来 ...
- Docker日常使用方式
前提 在安装docker之前,建议你设置系统的国内镜像源先哦,很快~嗯,快. 阿里云镜像源:https://developer.aliyun.com/mirror/ 安装 安装docker 下面都是官 ...
- 前端路由、后端路由——想要学好vue-router 或者 node.js 必须得明白的两个概念
前端路由和后端路由的概念讲解 引言 正文 一.路由的概念 二.后端路由 三.前端路由 四.其他知识 结束语 引言 无论你是正在学习vue 还是在学习node, 你一定会碰到前端路由和后端路由这两个概念 ...
- phpstudy后门利用复现
一.漏洞位置 程序自带的PHP的php_xmlrpc.dll模块中有隐藏后门,受影响的版本有phpstudy2016(php5.2/5.4).phpstudy2018(php5.2/5.4)等版本. ...
- 贫血模型和DDD模型
贫血模型和DDD模型 1.贫血模型 1.1 概念 常见的mvc三层架构 简单.没有行为 2.领域驱动设计 2.1 概念(2004年提出的) Domain Driven Design 简称 DDD DD ...
- jsoup中selector的用法及作用
1.jsoup——selector定义: selector选择器是用于对jsoup解析后document文档的数据筛选操作 2.jsoup——selector操作步骤: 1)先导jsoup架包 2)基 ...
- 保护wordpress后台登录地址
前几天有个群友的wordpress网站被后台入侵了,吓得我赶紧看了看网站日志,密密麻麻的404,扫描我的后台登录地址.还好之前有了安全措施: 纯代码保护后台登录地址,防止爆破 //保护后台登录add_ ...
- 超级码力编程赛带着6万奖金和1200件T恤向你跑来了~
炎炎夏日,总是感觉很疲劳,提不起一点精神怎么办?是时候参加一场比赛来唤醒你的激情了!阿里云超级码力在线编程大赛震撼携手全国数百所高校震撼来袭. 它来了,它来了,它带着60000现金和1200件T恤向你 ...