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. 提升ReSharper和Visual Studio的性能

    转载 作者:赵青青        出处:http://www.cnblogs.com/zhaoqingqing/ 文章目录[点击展开](?)[+]   提升性能 我们不断地确保ReSharper的正常 ...

  2. Hadoop HDFS (3) JAVA訪问HDFS

    如今我们来深入了解一下Hadoop的FileSystem类. 这个类是用来跟Hadoop的文件系统进行交互的.尽管我们这里主要是针对HDFS.可是我们还是应该让我们的代码仅仅使用抽象类FileSyst ...

  3. 第二篇:基于K-近邻分类算法的约会对象智能匹配系统

    前言 假如你想到某个在线约会网站寻找约会对象,那么你很可能将该约会网站的所有用户归为三类: 1. 不喜欢的 2. 有点魅力的 3. 很有魅力的 你如何决定某个用户属于上述的哪一类呢?想必你会分析用户的 ...

  4. POJ 3162 Walking Race(树的直径+单调队列)

    题目大意:对一棵树,求出从每个结点出发能到走的最长距离(每个结点最多只能经过一次),将这些距离按排成一个数组得到dis[1],dis[2],dis[3]……dis[n] ,在数列的dis中求一个最长的 ...

  5. python简单小爬虫爬取易车网图片

    上代码: import requests,urllib.request from bs4 import BeautifulSoup url = 'http://photo.bitauto.com/' ...

  6. BeautifulSoup在Windows下安装(running 2to3)

    在windows下安装beautifulsoup经常会出现说是在python3下无法运行Python2的代码,这时需要将Python下的tool下的scripts目录添加到环境变量中,然后运行2to3 ...

  7. VB 增强的部件与引用

    常用部件 对话框 Microsoft Common Dialog Control 6.0 (sp6) COMDLG32.OCX Forms2.0控件        Microsoft Forms 2. ...

  8. aspx页面中获取当前浏览器url

    /假设当前浏览器地址为:http://www.360.net.cn/Group/Index.aspx?id=123 这其中如下介绍: ①."http://"是协议名 ②." ...

  9. p标签里面不能嵌套div

    先申明本人代码水平为零起点,刚开始学习前端,所以就是小白.不过大神也是小白变身的么,所以要专心码代码,潜心钻研,haha~ 今天练习了段代码,发现效果和自己想象的不一样: 想了一下估计是<p&g ...

  10. jquery的ajax方法:ajaxStart()和ajaxStop()

    ajaxStart()方法: 当AJAX请求开始时,显示加载中的提示. $("#divMessage").ajaxStart(function(){ $(this).show(); ...