http://www.lightoj.com/volume_showproblem.php?problem=1062

题意:问两条平行边间的距离,给出从同一水平面出发的两条相交线段长,及它们交点到水平面的高。

思路:计算几何怎么可能直接算出答案orz解了好久方程觉得不对,应该是二分枚举平行边的距离,通过相似三角形,算出交点的高,与题目比较,小于误差范围就行了。

/** @Date    : 2016-12-10-18.18
* @Author : Lweleth (SoungEarlf@gmail.com)
* @Link : https://github.com/
* @Version :
*/
#include<bits/stdc++.h>
#define LL long long
#define PII pair
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std; const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8; int main()
{
int T;
int cnt = 0;
cin >> T;
while(T--)
{
double x, y, c;
scanf("%lf%lf%lf", &x ,&y ,&c);
double h1, h2, m;
double s = 0;
double l = 0, r = min(x, y);
while(r - l > eps)
{
m = (l + r) / 2.00;
//cout << m << " ";
h1 = sqrt(x * x - m * m);
h2 = sqrt(y * y - m * m);
s = h1 * h2 / (h1 + h2);
//cout << s << " ";
if(fabs(s - c) <= eps)
break;
else if(s < c)
r = m;
else if(s > c)
l = m;
}
printf("Case %d: %.8lf\n", ++cnt, m);
}
return 0;
}

LightOJ 1062 - Crossed Ladders 基础计算几何的更多相关文章

  1. LightOJ 1137 - Expanding Rods 基础计算几何

    http://www.lightoj.com/volume_showproblem.php?problem=1137 题意:一根长度为L的杆热膨胀为L',左端点到右端点间距离不变,且膨胀后的杆的弧为圆 ...

  2. 二分---LIGHTOJ 1062

    1062 - Crossed Ladders PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB A ...

  3. Crossed Ladders 求街道宽度 (二分法)

    Description A narrow street is lined with tall buildings. An x foot long ladder is rested at the bas ...

  4. poj1584 A Round Peg in a Ground Hole 判断多边形凹凸,点到线的距离【基础计算几何】

    大致思路:首先对于所给的洞的点,判断是否是凸多边形,图形的输入和输出可以是顺时针或者逆时针,而且允许多点共线 Debug 了好几个小时,发现如下问题 判断三点是否共线,可用斜率公式判断 POINT p ...

  5. Kuangbin 带你飞-基础计算几何专题 题解

    专题基本全都是模版应用.贴一下模版 平面最近点对 const double INF = 1e16; ; struct Point { int x,y; int type; }; double dist ...

  6. kuangbin专题十三-基础计算几何

    链接:https://cn.vjudge.net/contest/68968 POJ 2318 TOYS 题意:m个玩具落在n+1个区间,给你玩具的坐标,问每个区间有多少玩具. 思路:叉积的简单应用, ...

  7. uva 10566 Crossed Ladders (二分)

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  8. lightoj刷题日记

    提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...

  9. 2018.07.04 POJ 1654 Area(简单计算几何)

    Area Time Limit: 1000MS Memory Limit: 10000K Description You are going to compute the area of a spec ...

随机推荐

  1. POJ 2986 A Triangle and a Circle(三角形和圆形求交)

    Description Given one triangle and one circle in the plane. Your task is to calculate the common are ...

  2. SGU 520 Fire in the Country(博弈+搜索)

    Description This summer's heat wave and drought unleashed devastating wildfires all across the Earth ...

  3. Log Files

    Description Nikolay has decided to become the best programmer in the world! Now he regularly takes p ...

  4. File Searching

    Description Have you ever used file searching tools provided by an operating system? For example, in ...

  5. 2019寒假训练营寒假作业(三) MOOC的网络空间安全概论笔记部分

    目录 第五章 网络攻防技术 5.1:网络信息收集技术--网络踩点 信息收集的必要性及内容 网络信息收集技术 网络踩点(Footprinting) 网络踩点常用手段 5.2:网络信息收集技术 --网络扫 ...

  6. (beta冲刺5/7)

    团队信息 队名:爸爸饿了 组长博客:here 作业博客:here 组员情况 组员1(组长):王彬 过去两天完成了哪些任务 推进后端完成安卓端接口的开发 在测试中发现返回地图接口存在错误(待修复) 推进 ...

  7. Martin Fowler关于IOC和DI的文章(原版)

    Inversion of Control Containers and the Dependency Injection pattern In the Java community there's b ...

  8. 【Linux】- Ubuntu安装redis,并开启远程访问

    Ubuntu16.04安装Redis 开启Redis远程访问的步骤: 1.注释掉redis配置文件中的,bind 127.0.0.1 sudo vi /etc/redis/redis.conf #注释 ...

  9. 修改QQ各版本的默认保存位置(聊天记录)

    这几天没少折腾windows,都有点烦了,我是那种有强迫症的,只要知道的自己没有做到的会感觉到浑身不爽的因为系统重装了好几次,QQ也没少安装几次,我使用的是TM的QQ(没有 那么多烦人的广告,娱乐组件 ...

  10. js 控制

    js 制动控制 代码 是 :setInterval(function(){$(".egg").click();},1000); 使用方法:调出浏览器放控制台(console),一般 ...