poj Fishnet
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的更多相关文章
- POJ 1408 Fishnet【枚举+线段相交+叉积求面积】
题目: http://poj.org/problem?id=1408 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...
- Fishnet(暴力POJ 1408)
Fishnet Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 1911 Accepted: 1227 Descripti ...
- POJ 1408:Fishnet
Fishnet Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 1921 Accepted: 1234 Descripti ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
随机推荐
- 嵌入式Linux的一点学习心得
Linux本身是一个发展中的操作系统.它有很多前期不完善的机制,被后代用新的机制代替.但是老的机制不可能一下子就消亡,因此由于“历史原因”,会产生很多新旧机制共存的情况.而且Linux的教科书数不胜数 ...
- JVM运行数据区
1.java虚拟机在运行的时候会把内存分为以下几个区域,如图:
- DataGridView绑定BindingList<T>带数据排序的类
本文章转载:http://yuyingying1986.blog.hexun.com/30905610_d.html DataGridView绑定List<T>类时候,不会自动的进行排序. ...
- android图片缓存框架Android-Universal-Image-Loader
http://blog.csdn.net/king_is_everyone/article/details/34107081 最近跟同学们做了一个创业项目,其实跟以前做项目不同,以前大多数都是做web ...
- SAP-MM:创建采购组织、采购组
创建采购组织 路径:SPRO – IMG – 企业结构 – 定义 – 物料管理 – 维护采购组织 操作: Step 1.点击"新条目". Step 2.维护"采购组织 ...
- PHP Predefined Interfaces 预定义接口(转)
SPL提供了6个迭代器接口: Traversable 遍历接口(检测一个类是否可以使用 foreach 进行遍历的接口) Iterator 迭代器接口(可在内部迭代自己的外部迭代器或类的接口) Ite ...
- GIT使用指南
安装git,svn,ant,maven并配置环境变量 1.拷贝settings.xml到用户目录的.m2目录下. 2.打开git命令行,使用如下命令生成公钥私钥 ssh-keygen -t rsa 3 ...
- Java基础知识强化之IO流笔记13:递归之不死神兔问题(斐波那契数列)
1.这个问题是如下的: 有一对兔子,从出生后第3个月起,每个月都生一对兔子,小兔子长到第3个月又生一对兔子,加入兔子都不死,问第20个月兔子的对数? 分析:我们找规律 兔子对数第1个月: 1 ...
- 体验Impress.js
用腻了ppt,prezi的风格看起来更酷一点儿,无意中得知有Impress.js这么一个H5版的prezi,nice,值得一试. 关于Impress.js,网上教程很多,但说实话就跟教小朋友一样,一步 ...
- entity 实体模型timeout设置
public Entities(): base("name=Entities") { var adapter = (IObjectContextAdapter)this; var ...