北大ACM3684——Physics Experiment

这题,题目的意思是,有N个球从高度为H的地方落下,每一秒落下一个球,球与球之间和球与地板直接都是弹性碰撞,求T秒后的每个球的位置,也就是高度。

这题,跟Ants那题类似,也就是球与球碰撞可以当作不转换方向,继续按照原来的方向。也就是R = 0的时候,忽略半径,算出每一个球的位置,每一个球与地板碰撞后,会上升到原来的高度。先算出一次掉落需要t = sqrt(2 * H / g);每个球总共的时间T,总共的完整的来回有k
= T / t
次。

k为奇数,最终高度为H - g * (k * t + t - T)^ 2

k为偶数,最终高度为H - g * (T - k * t)^ 2

算出每一个球,排序后,就是各个球最终的位置,不过球的R为0.

因为R 大于等于1。所以,最后加上2 * i * R / 100.0就OK了,i是第i个球,因为R的单位是厘米,所以除以100.0。

下面的是AC的代码:

#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;

int N, H, R, T;
const double g = 10.0;
double y[105];
double fun(int t)
{
	if(t < 0)
		return H;
	double d;
	double temp = sqrt(2 * H / g);
	int k = int(t / temp);
	if(k % 2 == 0)
	{
		d = t - temp * k;
	}
	else
	{
		d = k * temp + temp - t;
	}
	return H - g * d * d / 2;
}

void solve()
{
	for(int i = 0; i < N; i++)
	{
		y[i] = fun(T - i);
	}
	sort(y, y + N);
	for(int j = 0; j < N; j++)
	{
		j == N - 1 ? printf("%.2lf\n", y[j] + 2 * R * j / 100.0) : printf("%.2lf ", y[j] + 2 * R * j / 100.0);
	}
}

int main()
{
	int c;
	scanf("%d", &c);
	while(c--)
	{
		scanf("%d%d%d%d", &N, &H, &R, &T);
		solve();
	}
	return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-08-27 19:33:27

北大ACM3684——Physics Experiment的相关文章

poj 3684 Physics Experiment 弹性碰撞

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,

POJ3684 Physics Experiment 【物理】

Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1031   Accepted: 365   Special Judge Description Simon is doing a physics experiment with N identical balls with the same radius of R centimeters. Before the experiment,

Physics Experiment poj 3684 弹性碰撞

Language: Default Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1107   Accepted: 380   Special Judge Description Simon is doing a physics experiment with N identical balls with the same radius of R centimeters. Befor

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 exper

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

物理实验 题目大意:有一个与地面垂直的管子,管口与地面相距H,管子里面有很多弹性球,从t=0时,第一个球从管口求开始下落,然后每1s就会又有球从球当前位置开始下落,球碰到地面原速返回,球与球之间相碰会发生完全弹性碰撞(各自方向改变,速率变为相碰时另一个球的速率)问最后所有球的位置? 这一题又是一道弹性碰撞模型的题目,和Liner World有点像,但是这一题不要求输出球的名字,而是要你求得各个球的高度 这道题我们只用明白一个道理就很方便了: 首先我们来看一个球的情况: 一个球从H的高度下落,碰到

POJ 3684 Physics Experiment

和蚂蚁问题类似. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<queue> #include<algorithm> using namespace std; int c,n; double h,r,t,T; double ans[105]; double cal(double time) { if(time<=0) re

POJ3684-Physics Experiment 弹性碰撞

Physics Experiment Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3576   Accepted: 1270   Special Judge Description Simon is doing a physics experiment with N identical balls with the same radius of R centimeters. Before the experiment,

Google学术指数2015版

除了影响因子,还有许多指标可以评价论文价值,如Google的H5指数H5中位数.现在JCR 的2015影响因子早已放出.Google也于6月份提供了其最新的2015学术指数.2015版的学术指数,是基于Google Scholor截止到2015月中旬索引的所有文献,涵盖了2010-2014年间的所有文献.Google的学术指数还包括网站遵循Google学术的纳入指标的文献. ? ? 英文文献Google学术指数前100名 ?? Publication h5-index h5-median 1.

弹性碰撞 poj 3684

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.