转化模型就变成几层折射率不同的玻璃光要怎么走才能从(0, 0)到(x, y)
我们发现第一次光线射出去的角度确定,之后光的行程是确定的
而且角度和最后到达y时的x成正相关,于是可以二分!
然后物理学学好就可以了QAQ
/**************************************************************
Problem: 3695
User: rausen
Language: C++
Result: Accepted
Time:24 ms
Memory:820 kb
****************************************************************/ #include <cstdio>
#include <cmath>
#include <algorithm> using namespace std;
typedef double lf;
const lf pi = acos(-1.0);
const lf eps = 1e-;
const int N = ; lf ans;
int n, x;
int h[N], v[N]; inline lf calc(lf now) {
lf res = , tmp = ;
int i;
for (i = ; i <= n; ++i) {
res += (lf) h[i] / tan(now);
tmp += (lf) h[i] / sin(now) / v[i];
now = pi / - asin(sin(pi / - now) * v[i + ] / v[i]);
}
ans = tmp;
return res;
} int main() {
int i;
scanf("%d%d", &n, &x);
for (i = ; i <= n; ++i) scanf("%d", h + i);
for (i = ; i <= n; ++i) scanf("%d", v + i);
lf l = , r = pi / , mid;
while (l + eps < r) {
mid = (l + r) / ;
if (calc(mid) <= x) r = mid;
else l = mid;
}
printf("%.3lf\n", ans);
return ;
}