csuoj-1712-Refract Facts
来源:互联网 发布:云计算股票龙头股 编辑:程序博客网 时间:2024/06/05 08:34
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
就是一个飞机给一个潜水艇发信号,然后潜水艇要给飞机发信号。然后告诉一x代表他们的距离,n1,n2分别代表水的折射率和空气的折射率,d是潜水艇深度,h是飞机高度,然后让你求潜水艇的仰角(仰角俯角分不清)
这题真是想了好久啊,乱推公式,发现一个高次的,果断gg,最后还是在队友的提醒下发现可以枚举角度什么的,然后就顺利ac了~~~
#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<iostream>using namespace std; #define PI 3.14159265358 int main(){ double d, h, x,n1, n2; while (scanf("%lf%lf%lf%lf%lf",&d,&h,&x,&n1,&n2)) { if (d==0&&h==0&&x==0&&n1==0&&n2==0) break; double ans = 90; double s = 0.0; double j; if (x == 0) { printf("90.00\n"); continue; } for(j=0.001;j<90;j+=0.001) { double xxx = j * PI / 180.0; double y = d / tan(xxx); if (x < y) continue; double yy = y * y; double xx = yy * (h * h + ((x - y) * (x - y))); double yyy = (yy + d * d) * (x - y) * (x - y); double fff = (n1 * n1) / (n2 * n2) - xx/yyy; if (fabs(fff-0.0) < ans) { ans = fabs(fff-0.0); s = j; //printf("%lf\n",s); } } printf("%.2lf\n",s); }}
0 0
- csuoj-1712-Refract Facts
- CSU 1712--Refract Facts
- 二分 csu1712 Refract Facts
- 湖南省多校对抗赛 Refract Facts
- CSUOJ
- CSUOJ
- csuoj--1307
- csuoj Lexicography
- csuoj X
- 1989CSUOJ
- The Facts
- CSUOJ优先队列
- CSUOJ 1165 枚举
- CSUOJ 1063 Sequence
- CSUOJ 1258 维护序列
- Random Integers+csuoj+dp
- CSUOJ--1563: Lexicography
- csuoj 2015.3.15
- (转)编码格式----乱码问题
- 亿级Web系统搭建——单机到分布式集群
- allinone—更亲密的接触
- 二分 csu1712 Refract Facts
- 新一代列式存储格式Parquet
- csuoj-1712-Refract Facts
- xListView上拉加载下拉刷新
- 正则表达式的相关内容
- leetcode 94. Binary Tree Inorder Traversal
- 1jar
- 一个分布式服务器集群架构方案
- 练习1-f
- Google Test
- 6.Java IO:字节和字符数组