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 ...
随机推荐
- PHP学习之[第09讲]PHP 的 Mysql 数据库函数 (微型博客系统)
一.数据库函数: mysql_connect(数据库地址,用户名,密码) mysql_select_db(数据库名) mysql_set_chartset(‘编码’) //PHP5.2.3以后的函数 ...
- 使用XStream注解实现Java对象与XML互相转换的代码示例
本文记录一下使用xstream这个api的注解特性对Java对象与XML字符串相互转换的一些代码示例. 我们很多人都处理过XML文件,也有很多非常成熟的第三方开源软件.如:jdom.dom4j等 ...
- JDK5-枚举
1. 使用普通类模拟枚举 public class Weekday { private Weekday() {} // 私有化 public static final Weekday MONDAY = ...
- 初学 Canvas <第一篇-基础篇>
本文摘自:兴趣部落大神(为你一生画眉)-讲一讲canvas究竟是个啥? HTML5 的标准已经出来好久了,但是似乎其中的 Canvas 现在并没有在太多的地方用到.一个很重要的原因是,Canvas 的 ...
- ACM比赛技巧
一.语言是最重要的基本功 无论侧重于什么方面,只要是通过计算机程序去最终实现的竞赛,语言都是大家要过的第一道关.亚洲赛区的比赛支持的语言包括C/C++与JAVA.笔者首先说说JAVA,众所周知,作 ...
- Dhroid框架笔记(DhNet、Adapter)
3.1.1 DhNet用于获取网络中的数据 DhNet net=new DhNet("路劲"); net.addParam("key", "参数&qu ...
- LinkButton和HyperLink的页面跳转用法
<%--<asp:HyperLink ID="HyperLink1" NavigateUrl='<%#"/Fxy_Admin/Pro_ClassNew. ...
- (转)ThinkPHP使用心得分享-分页类Page的用法
转之--http://www.jb51.net/article/50138.htm ThinkPHP中的Page类在ThinkPHP/Extend/Library/ORG/Util/Page.clas ...
- 转:常用的HTML标签和属性解释
基本结构标签: <HTML>,表示该文件为HTML文件 <HEAD>,包含文件的标题,使用的脚本,样式定义等 <TITLE>---</TITLE>,包含 ...
- MySQL UPDATE
MySQL UPDATE 查询 如果我们需要修改或更新MySQL中的数据,我们可以使用 SQL UPDATE 命令来操作.. 语法 以下是 UPDATE 命令修改 MySQL 数据表数据的通用SQL语 ...