WOJ1119-Model Rocket Height

One method for determining the height achieved by a model rocket is to have three observers A, B and C equally spaced D feet apart along a 
line at one edge of the flat test field. Each observer has a theodolite or some other device for measuring angle above the horizontal of a 
distant object. Each measuring device is on a stand H feet above the field. When a rocket is fired, near the top of its flight, it deploys a 
parachute and emits a puff of dust. Each observer measures the angle above the horizontal of the puff of dust from their location. From these 
angles α for A, β for B and γ for C, the height of the rocket above the field can be determined. 

This problem is to write a program which, given the parameters D (the distance between observers along the line in feet), H (the distance of 
the measuring device above the field in feet), α (the angle of the rocket above the horizontal in degrees measured by the leftmost observer 
A), β (the angle above the horizontal in degrees observed by the center observer B) and γ (the angle above the horizontal in degrees 
measured by the rightmost observer C), computes the height of the rocket above the field in feet to the nearest foot. 

输入格式

The first line of input contains the parameters D and H in that order as decimal numbers (not necessarily integers). These values would be
measured once at the beginning of the day and remain fixed through all rocket shots. Each succeeding line of input will contain the angles α,
β and γ in that order (measured in degrees). The last line of input will contain at least one value less than or equal to zero. Other than the last line indicating the end of data all angles will be strictly between 0 and 90 degrees.

输出格式

For each set of three angles (other than the end indicator), the output contains a line with the height above the field in feet (to the
nearest foot) with no leading spaces. (Note: x.5 rounds up to x+1.)

样例输入

50 4
43.88 46.85 40.70
34.52 39.50 35.43
27.05 29.22 26.14
0 0 0

样例输出

90
70
60

根据题意画图,在两个小三角形和一个大三角形中找关系,根据余弦定理列出方程,解方程可得答案,别忘了加上观测器的高度。

#include<stdio.h>
#include<math.h>
#define pi acos(-1.0)
int main(){
	float d,h,a,b,c,ans;
	int daan;
	scanf("%f %f",&d,&h);
	while(scanf("%f %f %f",&a,&b,&c)==3){
		if(a<=0||b<=0||c<=0)
		break;
		a=a/180*pi;
		b=b/180*pi;
		c=c/180*pi;
		ans=sin(b)*sqrt(2*d*d/(sin(b)*sin(b)/sin(a)/sin(a)+sin(b)*sin(b)/sin(c)/sin(c)-2));
		daan=ans+h+0.5;
		printf("%d\n",daan);		
	}
	return 0;
} 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值