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

最新文章

  1. Leetcode Substring with Concatenation of All Words
  2. grub的sol
  3. QQ(iOS)客户端的粘性动画效果
  4. foreach属性-动态-mybatis中使用map类型参数,其中key为列名,value为列值
  5. android自定义viewgroup实现等分格子布局
  6. iOS开发数据库SQLite的使用
  7. 使用GSoap开发WebService客户端与服务端
  8. Android 数据库ORM框架GreenDao学习心得及使用总结&lt;一&gt;
  9. Qt分析:Qt中的两种定时器(可是QObject为什么要提高定时器呢,没必要啊。。。)
  10. 【POJ3037】Skiing 最短路
  11. CF/div2c/贪心
  12. UILable添加事件
  13. 数据库 SQL Server2012安装步骤详解
  14. centOS7在VirtualBox中装好后的网络连接问题
  15. zepto与jquery冲突的解决
  16. 20165306 Exp3 免杀原理与实践
  17. Akka-Cluster(0)- 分布式应用开发的一些想法
  18. 9个Linux系统常用监控命令
  19. python dict交换key value值
  20. xpath定位相邻元素方法

热门文章

  1. R语言预测实战(游浩麟)笔记1
  2. coreData的ManagedObject后,报错
  3. 九州动态ip的特色
  4. SecureCRT标签显示标题
  5. 实训任务05 MapReduce获取成绩表的最高分记录
  6. ansible-play中role的基本用法
  7. X-template
  8. 在当前TestSuite/TestCase run之前先run另一个TestSuite/TestCase
  9. SQL Server用表组织数据
  10. Sublime使用及配置C编译器