Physics Experiment 物理题

知道下面这两个结论题目就会辣

1.球心发生弹性碰撞的相同两球,相当于速度交换

2.每个球只能在h范围内进行变化,因为之前落下的会占据高度,这个球下面一定有前面落下球的个数

然后把所有时间求得的高度排序就好了


/*  ^^ ====== ^^ 
ID: meixiuxiu
PROG: test
LANG: C++11
*/
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <cctype>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int ,int> pii;
#define MEM(a,b) memset(a,b,sizeof a)
#define CLR(a) memset(a,0,sizeof a);
#define pi acos(-1.0)
#define maxn 40000
#define maxv 100005
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
//#define LOCAL
double ans[105];
int n,h,r,t;
double cal(int t){
	if(t<0)return h;
	double t1 = sqrt(2.0*h/10);
	int cnt = (int)t/t1;
	double remid = t - cnt*t1;
	double v0 = sqrt(2*10.0*h);
	if(cnt%2){
		remid = cnt*t1+t1-t;
		return h-1.0/2*10*remid*remid;
	}
	else return h-1.0/2*10*remid*remid;
}
int main()
{
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
//	freopen("out.txt","w",stdout);
#endif
	int c;scanf("%d",&c);
	while(c--){
		scanf("%d%d%d%d",&n,&h,&r,&t);
		for(int i=0;i<n;i++){
			double hh = cal(t-i);
			ans[i] = hh;
		}
		sort(ans,ans+n);
		for(int i=0;i<n;i++){
			printf("%.2f%c",ans[i]+2*r*i/100.0,i==n-1?'\n':' ');
		}
	}
	return 0;
}


你可能感兴趣的:(ACM)