ICPC 6921 Refraction


一个水槽如图

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;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值