二分 csu1712 Refract Facts
来源:互联网 发布:云计算股票龙头股 编辑:程序博客网 时间:2024/06/05 09:41
传送门:点击打开链接
题意:告诉你水的折射率,潜艇的深度,飞机的高度,两个的水平距离之差,求角度
思路:设飞机到视线进入水面的那个点的垂线距离为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;}
0 0
- 二分 csu1712 Refract Facts
- csuoj-1712-Refract Facts
- CSU 1712--Refract Facts
- 湖南省多校对抗赛 Refract Facts
- The Facts
- Fast Facts of China
- zoj1222 Just the Facts
- facts in prolog
- 1199: Just the Facts
- Just the Facts(P1604)
- Facts About Fingerprints
- 568 - Just the Facts
- 568 - Just the Facts
- 568 - Just the Facts
- uva568 Just the Facts
- UVa568 Just the Facts
- Just the Facts
- toj2034 Just the Facts
- Python1————安装
- 一个简单的猜数字游戏
- (转)编码格式----乱码问题
- 亿级Web系统搭建——单机到分布式集群
- allinone—更亲密的接触
- 二分 csu1712 Refract Facts
- 新一代列式存储格式Parquet
- csuoj-1712-Refract Facts
- xListView上拉加载下拉刷新
- 正则表达式的相关内容
- leetcode 94. Binary Tree Inorder Traversal
- 1jar
- 一个分布式服务器集群架构方案
- 练习1-f