http://poj.org/problem?id=1408

 #include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define maxn 1000
using namespace std; const double eps=1e-;
const double pi=acos(-1.0); 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 point &a,const double b)
{
return point (a.x*b,a.y*b);
}
friend point operator / (const point &a,const double b)
{
return point(a.x/b,a.y/b);
}
};
struct line
{
point a,b;
line(){}
line(point x,point y):a(x),b(y){}
};
inline double sqr(double x)
{
return x*x;
}
double det(point a,point b)
{
return a.x*b.y-a.y*b.x;
}
double dot(point a,point b)
{
return a.x*b.x+a.y*b.y;
}
double dist(point a,point b)
{
return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));
}
double area(point a[])
{
double sum=;
a[]=a[];
for(int i=; i<; i++)
{
sum+=det(a[i+],a[i]);
}
return sum/;
} 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=(a.b*s1-a.a*s2)/(s1-s2);
return true;
} int main()
{
int n;
double a[maxn],b[maxn],c[maxn],d[maxn];
point m[][];
line l[][];
while(scanf("%d",&n)&&n){
double max1=eps;
for(int i=; i<=n; i++){
scanf("%lf",&a[i]);
m[][i].x=a[i];
m[][i].y=; }
m[][].x=;
m[][].y=;
m[][n+].x=;
m[][n+].y=;
for(int j=; j<=n; j++){
scanf("%lf",&b[j]);
m[n+][j].x=b[j];
m[n+][j].y=;
}
m[n+][].x=;
m[n+][].y=;
m[n+][n+].x=;
m[n+][n+].y=;
for(int k=; k<=n; k++){
scanf("%lf",&c[k]);
m[k][].y=c[k];
m[k][].x=;
}
for(int t= ; t<=n; t++){
scanf("%lf",&d[t]);
m[t][n+].x=;
m[t][n+].y=d[t];
}
for(int i=; i<=n; i++)
{
l[i][].a=m[][i];
l[i][].b=m[n+][i];
}
for(int i=; i<=n; i++)
{
l[][i].a=m[i][];
l[][i].b=m[i][n+];
}
for(int i=; i<=n; i++)
{
for(int j=; j<=n; j++)
{
point res;
line_make_point(l[][i],l[j][],res);
m[i][j]=res;
}
}
for(int i=; i<=n+; i++)
{
for(int j=; j<=n+; j++)
{
point s[];
s[]=m[i-][j-];
s[]=m[i-][j];
s[]=m[i][j];
s[]=m[i][j-];
max1=max(max1,area(s));
//printf("%.6lf ",area(s));
}
//printf("\n");
}
printf("%.6lf\n",max1);
}
return ;
}

poj Fishnet的更多相关文章

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

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

  2. Fishnet(暴力POJ 1408)

    Fishnet Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 1911   Accepted: 1227 Descripti ...

  3. POJ 1408:Fishnet

    Fishnet Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 1921   Accepted: 1234 Descripti ...

  4. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  5. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  6. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  7. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  8. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  9. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

随机推荐

  1. Java中this的功能与作用

    粗粒度上来说,Java中关键字this主要有2个功能: 1.表示“当前对象”的引用 (1)作为参数传入 [程序实例1] public class MyObject { public Integer v ...

  2. 表格布局TableLayout

    简单实现计算机界面布局的案例: <?xml version="1.0" encoding="utf-8"?><TableLayout xmln ...

  3. Android图片框架---Glide

    Glide *** 使用* 一.添加依赖* compile 'com.github.bumptech.glide:glide:3.7.0'* compile 'com.android.support: ...

  4. 使用easy_install安装numpy、pandas、matplotlib及各种第三方模块

    倒腾了一晚上最终把题目中的环境配好了.以下简要说明.留作资料.并共享. 1.安装python. 在cmd中能进入python环境,通过把python路径加入到系统路径中就可以实现. 2.安装easy- ...

  5. sync fsync fdatasync ---systemtap跟踪

    aa.stp: probe kernel .function ( "sys_sync" ) { printf ( "probfunc:%s fun:%s\n", ...

  6. QT unit test code coverage

    准备环境: qt-creator5.2.1 , gcov(gcc 默认安装),lcov(gcov 的图形化显示界面),qt_testlib 各环境介绍: 1.gcov   gcov 是一个可用于C/C ...

  7. poj 1811 Pallor Rho +Miller Rabin

    /* 题目:给出一个数 如果是prime 输出prime 否则输出他的最小质因子 Miller Rabin +Poller Rho 大素数判定+大数找质因子 后面这个算法嘛 基于Birthday Pa ...

  8. Miller_Rabin codevs 1702 素数判定2

    /* 直接费马小定理 */ #include<iostream> #include<cstdio> #include<cstdlib> #include<ct ...

  9. 转载:C# 之泛型详解

    本文原地址:http://www.blogjava.net/Jack2007/archive/2008/05/05/198566.html.感谢博主分享! 什么是泛型 我们在编写程序时,经常遇到两个模 ...

  10. Android中px、dp、sp的区别

    px: 即像素,1px代表屏幕上一个物理的像素点: px单位不被建议使用,因为同样100px的图片,在不同手机上显示的实际大小可能不同,如下图所示(图片来自android developer guid ...