CSU 1712--Refract Facts

来源:互联网 发布:白金数据 东野圭吾 编辑:程序博客网 时间:2024/06/15 13:25


Refract Facts
Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%lld & %llu
Submit Status Practice CSU 1712

Description

Input

Output

Sample Input

600 600 1000 1.333 1.01600 1200 4000 1.5 1.01400 100 10000 2.5 1.010 0 0 0 0

Sample Output

44.3711.512.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-6int main(){#ifdef OFFLINEfreopen("t.txt", "r", stdin);#endifdouble 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;elser = mid;}printf("%.2lf\n", 90 - r);}return 0;}





















0 0
原创粉丝点击