传送门:点击打开链接
题意:告诉你水的折射率,潜艇的深度,飞机的高度,两个的水平距离之差,求角度
思路:设飞机到视线进入水面的那个点的垂线距离为m,然后我们就可以根据折射率,列出表达式。
这种题目猜都能大致猜出,应该是有单调性,可以二分的,xjb随便先试试l=m,再试试r=m,总有一个是对的23333
要注意输出的是角度,所以要把弧度换算成角度输出
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <bitset>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <functional>
#define fuck(x) cout << "[" << x << "]"
#define FIN freopen("input.txt", "r", stdin)
#define FOUT freopen("output.txt", "w+", stdout)
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
double d, h, x, n1, n2;
const double pi = acos(-1.0);
double solve() {
double l = 0, r = x, m;
for(int i = 0; i < 100; i++) {
m = (l + r) / 2;
double t1 = (x - m) / d, t2 = m / h;
double f = t1 * t1 * (t2 * t2 + 1) / ((t1 * t1 + 1) * t2 * t2) - n1 * n1 / n2 / n2;
if(f < 0) r = m;
else l = m;
}
double ans = atan(d / (x - l));
return ans / pi * 180;
}
int main() {
//FIN;
while(~scanf("%lf%lf%lf%lf%lf", &d, &h, &x, &n1, &n2)) {
if(n1 < 0.5) break;
printf("%.2f\n", solve());
}
return 0;
}