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. Android Dialog触摸对话框外部让其消失的实现方法

    方法一: @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent ...

  2. Leetcode - Reverse Words

    比起POJ弱爆了一题,从后往前扫描一遍,O(n)时间,仅仅要注意各种极端情况就可以,不明确通过率为什么仅仅有13%. #include<iostream> #include<stri ...

  3. jquery自定义插件来实现分页的效果

    本节将介绍如何定义自己的jquery插入,实现分页效果,话不多说,.看看达到的效果: 分页插件 实现的代码例如以下: <!DOCTYPE HTML PUBLIC "-//W3C//DT ...

  4. MYSQL 体系结构图

  5. 从零开始学习jquery (二)

    前面我们了解到了如何获取使用jquery,下面我们主要看看jquery的一些语法.基本的语法 $(selector).action(). 美元符号定义 jQuery 选择符(selector)&quo ...

  6. 网络环境场景以及模拟工具netem

    网络环境场景包括: 延迟(Lag),把数据包缓存一段时间后再发出,这样能够模拟网络延迟的状况. 掉包(Drop),随机丢弃一些数据. 节流(Throttle),把一小段时间内的数据拦截下来后再在之后的 ...

  7. 第四节:教你如何快速让浏览器兼容ES6特性

    写在正文前,本来这一节的内容应该放在第二节更合适,因为当时就有同学问ES6的兼容性如何,如何在浏览器兼容ES6的特性,这节前端君会介绍一个抱砖引玉的操作案例. 为什么ES6会有兼容性问题? 由于广大用 ...

  8. (总结)Nginx配置文件nginx.conf中文详解 <转>

    转自 http://www.ha97.com/5194.html #定义Nginx运行的用户和用户组user www www; #nginx进程数,建议设置为等于CPU总核心数.worker_proc ...

  9. HDU5308-脑补-对拍

    先贴上对拍的结果: 感想:可以明显发现下标相差1的关系,所以对付这种需要大量脑补的水题,真的蛋疼,以前没用过对拍,只知道有这么回事,调程序什么的都是手算,人工模拟(经常大脑发热,严重缺氧不足),所以试 ...

  10. KMP算法总结

    kmp算法的T子字符串的下标的变化规律 大话数据结构这边书中的KMP算法的讲解跟最终的算法代码还是有很大的差别 java语言只会if判断语句,循环语句,但是这些语句以及可以包罗万象了,可以适用很多情况 ...