CSU 1712--Refract Facts


Refract Facts
Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%lld & %llu

Description

Input

Output

Sample Input

600 600 1000 1.333 1.01
600 1200 4000 1.5 1.01
400 100 10000 2.5 1.01
0 0 0 0 0

Sample Output

44.37
11.51
2.30

Hint

题意:如图所示,已知 d, h, x, n1, n2 及角 1 和角 2 与 n1 和 n2 的关系,求海艇发射信息的角度。

思路:在 0--90 之内二分角 1 ,得到结果的余角即为答案。

代码如下:

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
#define pi 3.1415926
#define eps 1e-6
int main()
{
#ifdef OFFLINE
	freopen("t.txt", "r", stdin);
#endif
	double h, d, x, n1, n2;
	while (~scanf("%lf%lf%lf%lf%lf", &d, &h, &x, &n1, &n2))
	{
		if (!h&&!d&&!x&&!n1&&!n2)  break;
		double mid, l = 0, r = 90, cta1, cta2;//二分cta1(角1)
		while (l + eps <= r)
		{
			mid = (l + r) / 2;
			cta1 = mid / 180 * pi;
			cta2 = asin(sin(cta1)*n2 / n1);
			if (d*tan(cta1) + h*tan(cta2) <= x)
				l = mid;
			else
				r = mid;
		}
		printf("%.2lf\n", 90 - r);
	}
	return 0;
}





















评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值