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 ...
随机推荐
- Hadoop入门--HDFS(单节点)配置和部署 (一)
一 配置SSH 下载ssh服务端和客户端 sudo apt-get install openssh-server openssh-client 验证是否安装成功 ssh username@192.16 ...
- Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.(转)
1.程序运行后异常显示: 解决方案:在项目上点击右键->properties->Java Build Path, remove掉Android Dependences即可
- html+css+js实现复选框全选与反选
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- oracle中的function 、procedure、packages、package bodies比较
1 function和procedure的区别 1).可以理解函数是存储过程的一种 2).函数可以没有参数,但是一定需要一个返回值,存储过程可以没有参数,不需要返回值 3).函数return返回值没 ...
- Log4net 配置注意事项
1. 首先引入Log4net程序集 2.修改webconfig配置文件 在 configuration 节点下面添加如下节点 <configSections> <section na ...
- UniqueID和ClientID的来源
在<漫话ID>一文中,作者提出了一个问题:为什么在ItemCreated事件中访问ClientID会导致MyButton无法响应事件,事实上 MyButton无法响应事件是因为他在客户端的 ...
- call()与apply()区别
一.方法的定义 call方法: 语法:call(thisObj,Object)定义:调用一个对象的一个方法,以另一个对象替换当前对象.说明:call 方法可以用来代替另一个对象调用一个方法.call ...
- Android中Application全局方法(变量)的调用
Application和Actovotu,Service一样是android框架的一个系统组件,当android程序启动时系统会创建一个 application对象,用来存储系统的一些信息.通常我们是 ...
- Java POI 导出excel表
1.首先下载poi-3.6-20091214.jar,下载地址如下: http://download.csdn.net/detail/evangel_z/3895051 2.Student.java ...
- (转)SQL Server中使用convert进行日期转换
原文链接:http://www.cnblogs.com/weiqt/articles/1826847.html SQL Server中使用convert进行日期转换 一般存入数据库中的时间格式为yyy ...