Regionals 2014 >> Asia - Dhaka >> 6921 - Refraction

题目:这里写图片描述
这里写图片描述

题目大意:求最少的水面高度,另眼睛所在位置能看到物体。

题目思路:这里写图片描述
经过P点黑色直线为水面高度为0时,且经过A点。
经过P点直线为经过x点根据u折射的直线,这可得P点高度是所需求h。
1.先求出角1的sin值
2.求出角1的tan值
3.根据三角形1和2相似,得出PH = (xe - W) * (H - h) / (ye - H),可知DE = W - PH - x;
4.化简方程组 h = ( W - PH - x) / tan_n;
如果h大于H,可知不存在h;如果h <= 0,h = 0;另外则输出h;

题目链接:6921 - Refraction

以下是代码:

#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、付费专栏及课程。

余额充值