#include  <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <list>
#include <map>
#include <set>
using namespace std;
const int maxn=;
const double eps=1e-;
int sgn(double x){ if(fabs(x) < eps) return ; if(x >) return ; return -; }
int dcmp(double x, double y){ if(fabs(x - y) < eps) return ; if(x > y) return ;return -;}
struct Point { double x,y; Point(double x,double y) { x=x;y=y; }; Point() {}; };
struct Segment{ Point a,b; Segment(Point x,Point y ) { a=x;b=y; }; Segment(){}; };
struct Line { Point a,b; Line(Point x,Point y ) { a=x;b=y; }; Line(){}; };
typedef Point Vector;
/*Vector operator + (Vector A, Vector B){ return Vector(A.x+B.x, A.y+B.y); } // 向量相加
Vector operator - (Point A, Point B){ return Vector(B.x-A.x, B.y-A.y); } // 向量生成 A-B;
double operator * (Vector A, Vector B){ return A.x*B.x-A.y*B.y; } // 点积
double operator ^ (Vector A, Vector B){ return A.x*B.y-A.y*B.x; } // 叉积*/
double Dot(Vector A, Vector B) { return A.x*B.x + A.y*B.y; } // 点积
double Cross(Vector A, Vector B) { return A.x*B.y-A.y*B.x; } // 叉积
double Length(Vector A) { return sqrt(Dot(A, A)); } // 向量长度
double dis(Point a,Point b) { return sqrt( (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y) ); }
Point pa[maxn];
Point pb[maxn];
Line sg[maxn];
int n;
double make(Line A,Line B)
{
Point a=A.a; Point b=A.b;Point c=B.a; Point d=B.b;
double A1=b.y-a.y,B1=-(b.x-a.x),C1=b.y*a.x-b.x*a.y;
double A2=d.y-c.y,B2=-(d.x-c.x),C2=d.y*c.x-d.x*c.y;
double k=A1*B2-A2*B1;
double x=-(B1*C2-C1*B2)*1.000000000/k;
double y=(A1*C2-C1*A2)*1.00000000/k;
return x;
}
bool co(Line A,Line B)
{
Point a=A.a; Point b=A.b; Point c=B.a; Point d=B.b;
Vector x,y,xxx,yyy;
x.x=c.x-a.x; x.y=c.y-a.y;
y.x=d.x-a.x; y.y=d.y-a.y;
xxx.x=c.x-b.x; xxx.y=c.y-b.y;
yyy.x=d.x-b.x; yyy.y=d.y-b.y;
if( Cross(x,y)*Cross(xxx,yyy)>eps ) return ;
else return ;
}
double work(Point xx,Point yy)
{
Line qq; qq.a=xx; qq.b=yy; //cout<<xx.x<<" "<<xx.y<<endl;
//cout<<yy.x<<" "<<yy.x<<endl; double ans=-1e18;
for(int i=;i<=n;i++)
{ if(i==)
{
if(co(sg[i],qq)==) return ans;
}
else
{
if(co(sg[i],qq)==) ans=max(ans,make(sg[i],qq));
else
{
if(co(Line(pa[i],pa[i-]),qq)==) ans=max(ans,make(Line(pa[i],pa[i-]),qq));
if(co(Line(pb[i],pb[i-]),qq)==) ans=max(ans,make(Line(pb[i],pb[i-]),qq));
break;
}
}
}
return ans;
}
bool up(Point a,Point b)
{
return a.x<b.x;
}
int main()
{
while()
{
scanf("%d",&n); if(n==) { break; }
for(int i=;i<=n;i++) { scanf("%lf %lf",&pa[i].x,&pa[i].y); } // xia mian dian
sort(pa+,pa++n,up);
for(int i=;i<=n;i++) { pb[i].x=pa[i].x; pb[i].y=pa[i].y+1.0; } // shang mian dian
for(int i=;i<=n;i++) { pa[i].y--; pb[i].y--; } // 下移
for(int i=;i<=n;i++) { sg[i].a=pa[i]; sg[i].b=pb[i]; } // a xiao b shang
double ans=-1e18;
for(int i=;i<=n;i++)
{
for(int j=i+;j<=n;j++) // end
{
ans=max(ans,work(pa[i],pa[j]));
ans=max(ans,work(pa[i],pb[j]));
ans=max(ans,work(pb[i],pa[j]));
ans=max(ans,work(pb[i],pb[j]));
}
//cout<<ans<<endl;
}
if(fabs(ans-pa[n].x)>eps ) printf("%.2f\n",ans);
else printf("Through all the pipe.\n");
}
return ;
}

poj 1039的更多相关文章

  1. poj 1039 Pipe(叉乘。。。)

    题目:http://poj.org/problem?id=1039 题意:有一宽度为1的折线管道,上面顶点为(xi,yi),所对应的下面顶点为(xi,yi-1),假设管道都是不透明的,不反射的,光线从 ...

  2. POJ - 1039 Pipe(计算几何)

    http://poj.org/problem?id=1039 题意 有一宽度为1的折线管道,上面顶点为(xi,yi),所对应的下面顶点为(xi,yi-1),假设管道都是不透明的,不反射的,光线从左边入 ...

  3. POJ 1039 Pipe【经典线段与直线相交】

    链接: http://poj.org/problem?id=1039 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...

  4. poj 1039 Pipe (Geometry)

    1039 -- Pipe 理解错题意一个晚上._(:з」∠)_ 题意很容易看懂,就是要求你求出从外面射进一根管子的射线,最远可以射到哪里. 正解的做法是,选择上点和下点各一个,然后对于每个折点位置竖直 ...

  5. nyoj 142, poj 1039 ,hdu 1454 管道问题

    http://acm.nyist.net/JudgeOnline/problem.php?pid=142 第一道解析几何问题,比较纠结,主要是几个解析几何的基本操作,包括求两线段的叉积,判断左右方向, ...

  6. 简单几何(直线与线段相交) POJ 1039 Pipe

    题目传送门 题意:一根管道,有光源从入口发射,问光源最远到达的地方. 分析:黑书上的例题,解法是枚举任意的一个上顶点和一个下顶点(优化后),组成直线,如果直线与所有竖直线段有交点,则表示能穿过管道. ...

  7. POJ 1039问题描述

    Description The GX Light Pipeline Company started to prepare bent pipes for the new transgalactic li ...

  8. POJ 1039 Pipe(直线和线段相交判断,求交点)

    Pipe Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8280   Accepted: 2483 Description ...

  9. POJ 1039 Pipe

    题意:一根管子,中间有一些拐点,给出拐点的上坐标,下坐标为上坐标的纵坐标减1,管子不能透过光线也不能折射光线,问光线能射到最远的点的横坐标. 解法:光线射到最远处的时候一定最少经过两个拐点,枚举每两个 ...

  10. poj 1039 Pipe(几何基础)

    Pipe Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9932   Accepted: 3045 Description ...

随机推荐

  1. 远程连接SqlServer 数据库时提示 "在与SQL Server 建立连接时出现与网络相关的或特定实例的错误" 解决方法

    前言 由于在之前的职业生涯中, 无论是数据库还是开发环境, 都是前人弄好的,自己只管使用就好啦.并不知安装过程中会出现各种各样的错.最近接触服务器之后,开发环境以及配置各方面都是从头到脚开始安装到配置 ...

  2. MySql主从搭建详细步骤

    环境: linux64位,一台机器两个实例,主库3306端口,从库3307端口 步骤: 一.下载安装 先下载安装mysql,这里使用了5.7.21版本,具体过程不做详细说明,可自行查资料如何下载 二. ...

  3. COPD——团队项目测试心得

    写在前面: 测试结束了,也要和项目说拜拜了~这一学期时间飞快,痛并快乐着,想想人生如果是个软件,那我们用多长时间在做测试呢?恐怕是一辈子.很多人忙着追逐,却很少人能停下来审视自己,那些时常自省的,常能 ...

  4. 类 Arrays StringBuilder 跟 StringBuffer 的异同 SimpleDateFormat

    类 String 同:起连接字符串类型作用 异: StringBuffer    //线程安全  效率慢 StringBuilder   //线程不安全  效率快 类 Arrays copyOf  ( ...

  5. javascript进阶高手必备知识

    不想当将军的士兵不是好士兵,想当将军那就意味着要学习更多的技能,进阶前端高手必备知识点都有哪些? 你知道作用域.原型.继承.作用域链.闭包等概念吗? 从浏览器多进程到JavaScript单进程你又理解 ...

  6. yum安装的Nginx添加第三方模块支持tcp

    需求:生产有个接口是通过socket通信.nginx1.9开始支持tcp层的转发,通过stream实现的,而socket也是基于tcp通信. 实现方法:Centos7.2下yum直接安装的nginx, ...

  7. Python第八章(北理国家精品课 嵩天等)

    程序设计方法 8.1体育竞技分析实例 from random import random def printIntro(): print("这个程序模拟两个选手A和B的某种竞技比赛" ...

  8. Shell 字符串处理

    字符串处理方式 计算字符串长度 获取子串在字符串中的索引位置 计算子串长度 抽取(截取)字串 1.计算字符串长度,有两种方式 $ ${#string} $ expr length "$str ...

  9. ubuntu安装ssh-service出现无法依赖的解决

    (1)首先先确认下ubuntu系统是否已经安装ssh(通常ubuntu中默认是安装的) 通过命令进行查看:$dpkg -l | grep ssh这里我们可以看到,系统显示已经安装了openssh-cl ...

  10. Sharepoint 2016 配置FBA(四)添加用户到Membership数据库

    现在还不能用FBA登录,因为数据库还没有用户. 有一些方法来管理membership数据库,有可以用IIS来管理.推荐使用 SharePoint 2016 FBA Pack(https://share ...