http://poj.org/problem?id=1408

  1. #include<cstdio>
  2. #include<cstring>
  3. #include<cmath>
  4. #include<algorithm>
  5. #define maxn 1000
  6. using namespace std;
  7.  
  8. const double eps=1e-;
  9. const double pi=acos(-1.0);
  10.  
  11. int cmp(double x)
  12. {
  13. if(fabs(x)<eps) return ;
  14. if(x>) return ;
  15. return -;
  16. }
  17.  
  18. struct point
  19. {
  20. double x,y;
  21. point(){}
  22. point(double a,double b):x(a),y(b) {}
  23. friend point operator -(const point &a,const point &b){
  24. return point(a.x-b.x,a.y-b.y);
  25. }
  26. friend point operator * (const point &a,const double b)
  27. {
  28. return point (a.x*b,a.y*b);
  29. }
  30. friend point operator / (const point &a,const double b)
  31. {
  32. return point(a.x/b,a.y/b);
  33. }
  34. };
  35. struct line
  36. {
  37. point a,b;
  38. line(){}
  39. line(point x,point y):a(x),b(y){}
  40. };
  41. inline double sqr(double x)
  42. {
  43. return x*x;
  44. }
  45. double det(point a,point b)
  46. {
  47. return a.x*b.y-a.y*b.x;
  48. }
  49. double dot(point a,point b)
  50. {
  51. return a.x*b.x+a.y*b.y;
  52. }
  53. double dist(point a,point b)
  54. {
  55. return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));
  56. }
  57. double area(point a[])
  58. {
  59. double sum=;
  60. a[]=a[];
  61. for(int i=; i<; i++)
  62. {
  63. sum+=det(a[i+],a[i]);
  64. }
  65. return sum/;
  66. }
  67.  
  68. bool parallel (line a,line b)
  69. {
  70. return !cmp(det(a.a-a.b,b.a-b.b));
  71. }
  72.  
  73. bool line_make_point(line a,line b,point &res)
  74. {
  75. if(parallel(a,b)) return false;
  76. double s1=det(a.a-b.a,b.b-b.a);
  77. double s2=det(a.b-b.a,b.b-b.a);
  78. res=(a.b*s1-a.a*s2)/(s1-s2);
  79. return true;
  80. }
  81.  
  82. int main()
  83. {
  84. int n;
  85. double a[maxn],b[maxn],c[maxn],d[maxn];
  86. point m[][];
  87. line l[][];
  88. while(scanf("%d",&n)&&n){
  89. double max1=eps;
  90. for(int i=; i<=n; i++){
  91. scanf("%lf",&a[i]);
  92. m[][i].x=a[i];
  93. m[][i].y=;
  94.  
  95. }
  96. m[][].x=;
  97. m[][].y=;
  98. m[][n+].x=;
  99. m[][n+].y=;
  100. for(int j=; j<=n; j++){
  101. scanf("%lf",&b[j]);
  102. m[n+][j].x=b[j];
  103. m[n+][j].y=;
  104. }
  105. m[n+][].x=;
  106. m[n+][].y=;
  107. m[n+][n+].x=;
  108. m[n+][n+].y=;
  109. for(int k=; k<=n; k++){
  110. scanf("%lf",&c[k]);
  111. m[k][].y=c[k];
  112. m[k][].x=;
  113. }
  114. for(int t= ; t<=n; t++){
  115. scanf("%lf",&d[t]);
  116. m[t][n+].x=;
  117. m[t][n+].y=d[t];
  118. }
  119. for(int i=; i<=n; i++)
  120. {
  121. l[i][].a=m[][i];
  122. l[i][].b=m[n+][i];
  123. }
  124. for(int i=; i<=n; i++)
  125. {
  126. l[][i].a=m[i][];
  127. l[][i].b=m[i][n+];
  128. }
  129. for(int i=; i<=n; i++)
  130. {
  131. for(int j=; j<=n; j++)
  132. {
  133. point res;
  134. line_make_point(l[][i],l[j][],res);
  135. m[i][j]=res;
  136. }
  137. }
  138. for(int i=; i<=n+; i++)
  139. {
  140. for(int j=; j<=n+; j++)
  141. {
  142. point s[];
  143. s[]=m[i-][j-];
  144. s[]=m[i-][j];
  145. s[]=m[i][j];
  146. s[]=m[i][j-];
  147. max1=max(max1,area(s));
  148. //printf("%.6lf ",area(s));
  149. }
  150. //printf("\n");
  151. }
  152. printf("%.6lf\n",max1);
  153. }
  154. return ;
  155. }

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. Hadoop入门--HDFS(单节点)配置和部署 (一)

    一 配置SSH 下载ssh服务端和客户端 sudo apt-get install openssh-server openssh-client 验证是否安装成功 ssh username@192.16 ...

  2. Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.(转)

    1.程序运行后异常显示: 解决方案:在项目上点击右键->properties->Java Build Path, remove掉Android Dependences即可

  3. html+css+js实现复选框全选与反选

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  4. oracle中的function 、procedure、packages、package bodies比较

    1  function和procedure的区别 1).可以理解函数是存储过程的一种 2).函数可以没有参数,但是一定需要一个返回值,存储过程可以没有参数,不需要返回值 3).函数return返回值没 ...

  5. Log4net 配置注意事项

    1. 首先引入Log4net程序集 2.修改webconfig配置文件 在 configuration 节点下面添加如下节点 <configSections> <section na ...

  6. UniqueID和ClientID的来源

    在<漫话ID>一文中,作者提出了一个问题:为什么在ItemCreated事件中访问ClientID会导致MyButton无法响应事件,事实上 MyButton无法响应事件是因为他在客户端的 ...

  7. call()与apply()区别

    一.方法的定义 call方法: 语法:call(thisObj,Object)定义:调用一个对象的一个方法,以另一个对象替换当前对象.说明:call 方法可以用来代替另一个对象调用一个方法.call ...

  8. Android中Application全局方法(变量)的调用

    Application和Actovotu,Service一样是android框架的一个系统组件,当android程序启动时系统会创建一个 application对象,用来存储系统的一些信息.通常我们是 ...

  9. Java POI 导出excel表

    1.首先下载poi-3.6-20091214.jar,下载地址如下: http://download.csdn.net/detail/evangel_z/3895051 2.Student.java ...

  10. (转)SQL Server中使用convert进行日期转换

    原文链接:http://www.cnblogs.com/weiqt/articles/1826847.html SQL Server中使用convert进行日期转换 一般存入数据库中的时间格式为yyy ...