团体程序设计天梯赛 L3-013 非常弹的球 (30分)

题目链接:

L3-013 非常弹的球 (30分)

思路:

我们由动能公式可以求得速度v=2Emv=\sqrt{\frac{2E}{m}}
设ang为θ\theta,则水平速度为vx=cosθ2Emv_{x}=\cos\theta\sqrt{\frac{2E}{m}},竖直速度为vy=sinθ2Emv_{y}=\sin\theta\sqrt{\frac{2E}{m}}
由于空气阻力等忽略不计,小球达到最高点所需时间t=vygt=\frac{v_{y}}{g},根据物理常识我们可知到达地面和升到最高点时间一致,因此从抛出到落地总时间为2t2t,小球水平移动的总距离s=2tvx=4Esinθcosθmg2Emgs=2tv_{x}=\frac{4E\sin\theta\cos\theta}{mg}\leq\frac{2E}{mg},当θ\thetaπ4\frac{\pi}{4}时取最大值;
似乎从地上再次弹起来的角度还是刚开始抛出的角度?不知道,物理都忘光了
然后依次开始下一个循环直到答案满足精度需求;

代码:

#include<bits/stdc++.h>

using namespace std;

const double eps = 1e-9;
const double g = 9.8;

int main() {
#ifdef MyTest
	freopen("Sakura.txt", "r", stdin);
#endif
	double w, p, ans = 0;
	scanf("%lf %lf", &w, &p);
	for(double e = 1000; e > eps; e *= 1 - p / 100) {
		ans += 200 * e / w / g;	
	}
	printf("%.3f", ans);
	return 0;
}
posted @ 2020-02-05 22:16  YuhanのBlog  阅读(206)  评论(0编辑  收藏  举报