Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 1642   Accepted: 1051

Description

A fisherman named Etadokah awoke in a very small island. He could see calm, beautiful and blue sea around the island. The previous night he had encountered a terrible storm and had reached this uninhabited island. Some wrecks of his ship were spread around him. He found a square wood-frame and a long thread among the wrecks. He had to survive in this island until someone came and saved him.

In order to catch fish, he began to make a kind of fishnet by cutting the long thread into short threads and fixing them at pegs on the square wood-frame. He wanted to know the sizes of the meshes of the fishnet to see whether he could catch small fish as well as large ones.

The wood frame is perfectly square with four thin edges on meter long: a bottom edge, a top edge, a left edge, and a right edge. There are n pegs on each edge, and thus there are 4n pegs in total. The positions of pegs are represented by their (x,y)-coordinates. Those of an example case with n=2 are depicted in figures below. The position of the ith peg on the bottom edge is represented by (ai,0). That on the top edge, on the left edge and on the right edge are represented by (bi,1), (0,ci) and (1,di), respectively. The long thread is cut into 2n threads with appropriate lengths. The threads are strained between (ai,0) and (bi,1),and between (0,ci) and (1,di) (i=1,...,n).

You should write a program that reports the size of the largest mesh among the (n+1)2 meshes of the fishnet made by fixing the threads at the pegs. You may assume that the thread he found is long enough to make the fishnet and the wood-frame is thin enough for neglecting its thickness. 
 

Input

The input consists of multiple sub-problems followed by a line containing a zero that indicates the end of input. Each sub-problem is given in the following format. 

a1 a2 ... an 
b1 b2 ... bn 
c1 c2 ... cn 
d1 d2 ... dn 
you may assume 0 < n <= 30, 0 < ai,bi,ci,di < 1

Output

For each sub-problem, the size of the largest mesh should be printed followed by a new line. Each value should be represented by 6 digits after the decimal point, and it may not have an error greater than 0.000001.

Sample Input

2
0.2000000 0.6000000
0.3000000 0.8000000
0.1000000 0.5000000
0.5000000 0.6000000
2
0.3333330 0.6666670
0.3333330 0.6666670
0.3333330 0.6666670
0.3333330 0.6666670
4
0.2000000 0.4000000 0.6000000 0.8000000
0.1000000 0.5000000 0.6000000 0.9000000
0.2000000 0.4000000 0.6000000 0.8000000
0.1000000 0.5000000 0.6000000 0.9000000
2
0.5138701 0.9476283
0.1717362 0.1757412
0.3086521 0.7022313
0.2264312 0.5345343
1
0.4000000
0.6000000
0.3000000
0.5000000
0

Sample Output

0.215657
0.111112
0.078923
0.279223
0.348958 题意:在一个边长为1的正方形(如图)的四个边上分别插入n个点,上和下,左和右分别对应点相连构成若干个线段,这些线段相交之后构成若干个四边形,问最大的那个四边形的面积;
先将对应点连起来构成线段,求出各个交点,这样就可以根据叉乘求出每个四边形的面积,比较之后得出最大的。我开始存输入的点的坐标时用的一位数组,结果找四边形对应顶点时就很麻烦,还是没想全面。改成二维数组后,p[i][j]就表示第i行第j个点的坐标,这样找四边形顶点坐标就好找了;
 #include<stdio.h>
#include<string.h>
#include<math.h> const double eps = 1e-;
int cmp(double x)
{
if(fabs(x) < eps)
return ;
if(x > ) return ;
return -;
} struct point
{
double x,y;
point(){}
point(double a,double b):x(a),y(b) {}
friend point operator - (const point &a, const point &b)
{
return point(a.x-b.x,a.y-b.y);
}
friend point operator * (const double &a, const point &b)
{
return point(a*b.x,a*b.y);
}
friend point operator / (const point &a, const double &b)
{
return point(a.x/b,a.y/b);
}
}p[][];//p[i][j]存第i行第j列交点处的点的坐标; struct line
{
point a,b;
line (){}
line(point x, point y):a(x),b(y) {}
}L[][];//存线段; double det(const point &a, const point &b)
{
return a.x * b.y - a.y * b.x;
}
bool parallel(line a,line b)
{
return !cmp(det(a.a-a.b,b.a-b.b));
}
bool line_make_point(line a,line b,point &res)
{
if(parallel(a,b)) return false;
double s1 = det(a.a-b.a,b.b-b.a);
double s2 = det(a.b-b.a,b.b-b.a);
res = (s1*a.b-s2*a.a)/(s1-s2);
return true;
}
double area(point a[])
{
double sum = ;
a[] = a[];
for(int i = ; i < ; i++)
sum += det(a[i+],a[i]);
return sum/;
}
int main()
{
int n;
while(~scanf("%d",&n) && n)
{
for(int i = ; i <= n; i++)
{
scanf("%lf",&p[][i].x);
p[][i].y = ;
}
p[][].x = ;
p[][].y = ;
p[][n+].x = ;
p[][n+].y = ; for(int i = ; i <= n; i++)
{
scanf("%lf",&p[n+][i].x);
p[n+][i].y = ;
}
p[n+][].x = ;
p[n+][].y = ;
p[n+][n+].x = ;
p[n+][n+].y = ; for(int i = ; i <= n; i++)
{
scanf("%lf",&p[i][].y);
p[i][].x = ;
}
for(int i = ; i <= n; i++)
{
scanf("%lf",&p[i][n+].y);
p[i][n+].x = ;
}
for(int i = ; i <= n; i++)
{
L[i][].a = p[][i];
L[i][].b = p[n+][i];
}
for(int i = ; i <= n; i++)
{
L[][i].a = p[i][];
L[][i].b = p[i][n+];
} for(int i = ; i <= n; i++)
{
for(int j = ; j <= n; j++)
line_make_point(L[][i],L[j][],p[i][j]);//横着第i条线段与竖着第j条线段的交点保存在p[i][j]中
} double max = eps;
for(int i = ; i <= n+; i++)
{
for(int j = ; j <= n+; j++)
{
point t[];
t[] = p[i][j-];
t[] = p[i][j];
t[] = p[i-][j];
t[] = p[i-][j-];//顺时针四个点的坐标;
double sum = area(t);
if(sum > max)
max = sum;
}
}
printf("%.6lf\n",max);
}
return ;
}
 

Fishnet(计算几何)的更多相关文章

  1. POJ 1408 Fishnet【枚举+线段相交+叉积求面积】

    题目: http://poj.org/problem?id=1408 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...

  2. ACM/ICPC 之 计算几何入门-叉积-to left test(POJ2318-POJ2398)

    POJ2318 本题需要运用to left test不断判断点处于哪个分区,并统计分区的点个数(保证点不在边界和界外),用来做叉积入门题很合适 //计算几何-叉积入门题 //Time:157Ms Me ...

  3. HDU 2202 计算几何

    最大三角形 Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  4. ACM 计算几何中的精度问题(转)

    http://www.cnblogs.com/acsmile/archive/2011/05/09/2040918.html 计算几何头疼的地方一般在于代码量大和精度问题,代码量问题只要平时注意积累模 ...

  5. hdu 2393:Higher Math(计算几何,水题)

    Higher Math Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  6. sdut 2603:Rescue The Princess(第四届山东省省赛原题,计算几何,向量旋转 + 向量交点)

    Rescue The Princess Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Several days ago, a b ...

  7. [知识点]计算几何I——基础知识与多边形面积

    // 此博文为迁移而来,写于2015年4月9日,不代表本人现在的观点与看法.原始地址:http://blog.sina.com.cn/s/blog_6022c4720102vxaq.html 1.前言 ...

  8. POJ 1106 Transmitters(计算几何)

    题目链接 切计算几何,感觉计算几何的算法还不熟.此题,枚举线段和圆点的直线,平分一个圆 #include <iostream> #include <cstring> #incl ...

  9. TYVJ计算几何

    今天讲了计算几何,发几道水水的tyvj上的题解... 计算几何好难啊!@Mrs.General....怎么办.... 这几道题都是在省选之前做的,所以前面的Point运算啊,dcmp啊,什么什么的,基 ...

随机推荐

  1. navigation的pushViewController卡顿问题

    问题:在ios中一个viewController中,添加下面代码: <pre name="code" class="objc">UIViewCont ...

  2. FaceBook要在视频领域打败YouTube?

    据<纽约时报>报道,FaceBook正在探索一项新的策略来直接把音乐视频嵌入到用户的News Feeds中.目前,具有代表性的视频网站有YouTube和Vimeo,它们可以在社交网络上分享 ...

  3. php代码优化技巧

    搬运: 1. 尽量采用大量的PHP内置函数. 2. echo 比print 快. 3. 不要把方法细分得过多,仔细想想你真正打算重用的是哪些代码? 4. 在执行for循环之前确定最大循环数,不要每循环 ...

  4. CentOS使用sendmail发送邮件

    1.安装sendmail yum -y install sendmail 2.启动sendmail服务 service sendmail start 3.将发件内容写入mail.txt mail -s ...

  5. PL/SQL 批量SQL

    批量SQL包括: FORALL语句 BULK COLLECT子句 FORALL语句 FORALL具有如下结构: FORALL loop_counter IN bounds_clause [SAVE E ...

  6. JAVA 生成PDF报表()

    许多应用程序都要求动态生成 PDF 文档.这些应用程序涵盖从生成客户对帐单并通过电子邮件交付的银行到购买特定的图书章节并以 PDF 格式接收这些图书章节的读者.这个列表不胜枚举.在本文中,我们将使用 ...

  7. Content Providers

    Content providers manage access to a structured set of data. They encapsulate the data, and provide ...

  8. 关于一点coding.net与git配合在AndroidStudio/Idea上的使用笔记个的

    编写程序的我们经常需要对我们写的代码做版本控制,或者分支管理,具备类似功能的软件很多,诸如SVN,Git,CVS等等!但配置版本控制服务器(SVN server etc.)是繁琐的并且需要一定的成本! ...

  9. ASP.NET实现二级域名(多用户,多商店)

    本人所了解有两种方案,可能还有其的方式,希望大家多多讨论!  基本思路:  1. 域名支持泛解析,即是指:把A记录 *.域名.com 解析到服务器IP,服务器IIS中做绑定,绑定时主机头为空;  2. ...

  10. Objective-C消息机制的原理

    http://desheng.me/2012/03/31/objective-c%E6%B6%88%E6%81%AF%E6%9C%BA%E5%88%B6%E7%9A%84%E5%8E%9F%E7%90 ...