ICPC 6921 Refraction
2015-09-03 13:11
302 查看
一个水槽如图
Input
First line of the input file contains an integer T (0 < T < 100001) which denotes the number of test cases. Each of the next T lines contains the input for one test case. Each line contains 5 integers W (100 ≤ W ≤ 1000), H (100 ≤ H ≤ 1000), x (1 ≤ x < W), xe(
W < xe ≤ 2000), ye (H < ye ≤ 2000) and a floating-point number µ (1.1000 ≤ µ ≤ 5.0000). The meaning of these symbols are given in the problem statement.
题意:判断一个点能不能被看到,如果能,输出水位最低高度
这题,二分高度不可以,有精度问题。应该从(X,0)点出发,假设水位高度,然后刚好能连到眼睛画线。
#include <vector> #include <map> #include <set> #include <algorithm> #include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #include <string> #include <cstring> using namespace std; const double EPS = 3 * 1e-6; int main(){ int t; cin >> t; while(t--) { double W,H,x,xe,ye; double u; cin >> W >> H >> x >> xe >> ye >> u; double sin_n = (xe - W) / sqrt((xe - W) * (xe - W) + (ye - H) * (ye - H)) / u; double tan_n = sin_n / sqrt(1 - sin_n * sin_n); double h = (((ye - H) * W - (ye - H) * x - H * (xe - W))) / ((ye - H) * tan_n - (xe - W)); if (h <= 0) h = 0; if (h > H) printf("Impossible\n"); else printf("%.4lf\n",h); } } return 0; }
相关文章推荐
- LTE学习:传输块大小的计算
- sharepoint 2013 全文搜索结果 点击弹出新页面
- 对数据按组排序
- 唐诗三百首
- Makefile文件编写
- 探寻社交网络中的关系: 统计网络模型初探
- 绘图与动画之使用自定义属性与图像掩膜实现灯泡开关动画
- 设计模式
- 第57讲:Scala中Dependency Injection实战详解学习笔记
- 欢迎使用CSDN-markdown编辑器
- 开学啦。又长大了一年。
- Project 2013 如何使用visual studio 2012 创建一个Project 2013的外接程序addin
- TCPIP三次握手
- 同步异步与阻塞非阻塞区别
- centos6系统启动流程
- nginx在fedora上的使用
- Unity 相关经典博客资源总结
- Word Ladder**
- poj 2411 Mondriaan's Dream (轮廓线DP)
- ubuntu14.04安装GTX850M显卡驱动实录