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. Google代码实验室

    https://code.google.com/p/google-styleguide/

  2. 关于css中伪类及伪元素的总结

    css中的伪类和伪元素总是混淆,今天参考了很多资料,也查看了部分文档,现将伪类及伪元素总结如下: 一.由来: 伪类和伪元素的引入都是因为在文档树里有些信息无法被充分描述,比如CSS没有"段落 ...

  3. AndroidStudio工程文件导入Jar包和So第三方库

    AndroidStudio 导入Jar包和第三方So库 在android开发中,需要导入许多第三方的jar包和so库来支持,包括像许多第三方的支持平台--友盟,环信.融云.极光推送.微博.腾讯等第三方 ...

  4. 9.28noip模拟试题

    1.栅栏迷宫 田野上搭建了一个黄金大神专用的栅栏围成的迷宫.幸运的是,在迷宫的边界上留出了两段栅栏作为迷宫的出口.更幸运的是,所建造的迷宫是一个“完美的”迷宫:即你能从迷宫中的任意一点找到一条走出迷宫 ...

  5. mysql隐藏文件一定要删除彻底

    之前部署自己的服务器机器的时候 机器的mysql密码是不知道的.彻底删除了软件之后还是解决不了问题,而且我把MYSQL在C盘的隐藏文件也给删除了.但是还是不行 最后我偶然发现一个方法去找隐藏问题.我之 ...

  6. Sharpdevelop使用StyleCop

    使用Visual Studio时,用resharper+stylecop感觉不错.后来因为单位电脑实在太卡,平时自己写个小片段什么的就用SharpDevelop,这里需要设置一下. 安装StyleCo ...

  7. ssh框架简单搭建

    这里是个人对SSH框架搭建的一点心得,仅供新手,勿喷 首先,搞清楚分层, 视图层 --> 控制层  --> 业务层 --> DAO层--> 持久层 搭建的顺序是从后向前,搭建一 ...

  8. Quartz.NET管理类

    最近做项目设计到Quartz.NET,写了一个Quartz.NET管理类,在此记录下. public class QuartzManager<T> where T : class,IJob ...

  9. Uri、UriMatcher、ContentUris详解

    http://blog.csdn.net/feng88724/article/details/6331396 1.Uri 通用资源标志符(Universal Resource Identifier, ...

  10. 【转】伟大的RAC和MVVM入门(一)

    原文:http://www.sprynthesis.com/2014/12/06/reactivecocoa-mvvm-introduction/   翻译自ReactiveCocoa and MVV ...