poj 3684 Physics Experiment 弹性碰撞
| Time Limit: 1000MS | Memory Limit: 65536K | |||
| Total Submissions: 1489 | Accepted: 509 | 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 ≤ 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
a,b两球碰撞时,由速度交换可知,可以当做a向上瞬移2*r,且保持原来的速度,b向下瞬移2*r,且可保持原来的速度,那么a能够达到的最大高度变成了原来的b的初始位置(假设b原来放在a的上方),b能够达到的最大高度就变成了a(因为瞬移的结果是增大了a的2*h的势能,削弱了b的2*h的势能),最终的结果是a变成了原来的b球,B变成了原来的a球,总的效果其实就是没有碰撞,多个球的于此类似。其实核心思想是,每次碰撞时,a球起初(刚释放时)势能要比b球少2*r(因为相对顺序不变),而碰撞后的瞬移使得a球增加了2*r的势能,b球减少了2*r的势能,因此最后变成了a比b还多了2*r的势能,也就是a,b的互换了。#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 ;
}
poj 3684 Physics Experiment 弹性碰撞的更多相关文章
- POJ 3684 Physics Experiment(弹性碰撞)
Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2936 Accepted: 104 ...
- 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
和蚂蚁问题类似. #include<cstdio> #include<cstring> #include<cmath> #include<vector> ...
- POJ:3684-Physics Experiment(弹性碰撞)
Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3392 Accepted: 1177 Sp ...
- Greedy:Physics Experiment(弹性碰撞模型)(POJ 3848)
物理实验 题目大意:有一个与地面垂直的管子,管口与地面相距H,管子里面有很多弹性球,从t=0时,第一个球从管口求开始下落,然后每1s就会又有球从球当前位置开始下落,球碰到地面原速返回,球与球之间相碰会 ...
- Physics Experiment 弹性碰撞 [POJ3684]
题意 有一个竖直的管子内有n个小球,小球的半径为r,最下面的小球距离地面h高度,让小球每隔一秒自由下落一个,小球与地面,小球与小球之间可视为弹性碰撞,让求T时间后这些小球的分布 Input The f ...
- Physics Experiment(POJ 3684)
原题如下: Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3583 Accepte ...
- 弹性碰撞 poj 3684
Simon is doing a physics experiment with N identical balls with the same radius of R centimeters. Be ...
- poj 3684
Physics Experiment Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 784 Accepted: 266 ...
随机推荐
- Ubuntu - Ubuntu应用记录(1)
1.发生dpkg status database is locked by another process 原因是包管理器没有正确关闭.需要重启计算机或者重新打开终端 输入: sudo rm /var ...
- servlet_cdi自动注入
@WebServlet("/cdiservlet")//url映射,即@WebServlet告诉容器,如果请求的URL是"/cdiservlet",则由NewS ...
- 【模板】SPFA(不完全详解)
一种最短路求法(个人觉得比DIJKSTRA好用) 用于有向图. 大概思路:从根节点开始,枚举每一个点,同时更新他们所联通的点的最短路径,如果路径被更新,则把这个点入队,一直重复这个操作直到队伍为空为止 ...
- hashmap存储数据
在HashMap中,为什么不能使用基本数据类型作为key? 其实和HashMap底层的存储原理有关,HashMap存储数据的特点是:无序.无索引.不能存储重复元素. 存储元素采用的是hash表存储数据 ...
- mongoose操作笔记
一.mongoose文档地址: https://cn.mongoosedoc.top/docs/api.html#update_update https://www.cnblogs.com/web-f ...
- 使用.NET Core创建Windows服务(一) - 使用官方推荐方式
原文:使用.NET Core创建Windows服务(一) - 使用官方推荐方式 原文:Creating Windows Services In .NET Core – Part 1 – The &qu ...
- php过滤微信昵称中的表情
function filterNickname($nickname) { $nickname = preg_replace('/[\x{1F600}-\x{1F64F}]/u', '', $nickn ...
- Vue中如何插入m3u8格式视频,3分钟学会!
大家都知道video只支持ogg.webm.MP4格式,但是要是m3u8格式的视频怎么办?最近遇到这个问题在网上找了好多办法都不行,最后找到video.js后才完美解决,所以决定写一 ...
- vue iview表格应用
今天看一下iview表格的使用.本文中有以下内容 table的必备部分(columns,data) render函数的使用(判断,添加样式,动态添加class...) slot使用 主要讲render ...
- fiddler抓包小技巧之自动保存抓包数据(可根据需求过滤)
首先 选择 如果有别的提示的话,你就按着提示走,就会安装一个编辑器,叫Fiddler Script. 正常情况下,你按着上面操作之后就会出现如下界面: 完事了之后,按下Ctrl+F来查找OnBefor ...