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. Javascript 函数和模块定义

    匿名函数 // calculator.js(function(root) {  var calculator = {    sum: function(a, b) { return a + b; }  ...

  2. xslt语法之---If Else

    大家都知道,XSL中是没有if else的,那么要想实现if else该怎么办呢? 其实很简单 <xsl:choose> <xsl:when test="position( ...

  3. linux 简单命令

    很久没有接触linux了,很多命令也忘记了,现在自己独立安装一个linux,独立安装LAMP,让自己记录下来这段. 怎么进入命令行 init 3, 回到桌面 init 5在不是root用户情况下,切换 ...

  4. java异常类的使用

    1.异常的概念 什么是异常?程序出错分为两部分,编译时出粗和运行时出错.编译时出错是编译器在编译源码时发生的错误: 运行时出错是在编译通过,在运行时出现的错误.这种情况叫异常. 例如:数组越界,除数为 ...

  5. 用java写bp神经网络(四)

    接上篇. 在(一)和(二)中,程序的体系是Net,Propagation,Trainer,Learner,DataProvider.这篇重构这个体系. Net 首先是Net,在上篇重新定义了激活函数和 ...

  6. 在模型中获取网络数据,刷新tableView

    model .h #import <Foundation/Foundation.h> #import "AFHTTPRequestOperationManager.h" ...

  7. 百度地图API地址转换成经纬度

    public class LngAndLatUtil { public static Map<String,Double> getLngAndLat(String address){ Ma ...

  8. js手机站跳转

    var yunzhuanhua_pc_domain = "http://www.域名.com#yht"; //PC站网址var yunzhuanhua_wap_domain = & ...

  9. One-day-学习笔记-商品成交时发送短信

    个人学习笔记(one) 根据需求:商品成交时发送短信 html代码省略..... Model代码省略..... /* * --------------------------------------- ...

  10. YII session存储 调用login方法

    当要进行用户的session存储的时候,可以调用里面的login方法进行存储