F - Herding

Time Limit:1000MS       Memory Limit:32768KB      64bit IO Format:%I64d & %I64u

Submit Status

Description

Little John is herding his father's cattles. As a lazy boy, he cannot tolerate chasing the cattles all the time to avoid unnecessary omission. Luckily, he notice that there were N trees in the meadow numbered from 1 to N, and calculated their cartesian coordinates (Xi, Yi). To herding his cattles safely, the easiest way is to connect some of the trees (with different numbers, of course) with fences, and the close region they formed would be herding area. Little John wants the area of this region to be as small as possible, and it could not be zero, of course.

Input

The first line contains the number of test cases T( T<=25 ). Following lines are the scenarios of each test case.  The first line of each test case contains one integer N( 1<=N<=100 ). The following N lines describe the coordinates of the trees. Each of these lines will contain two float numbers Xi and Yi( -1000<=Xi, Yi<=1000 ) representing the coordinates of the corresponding tree. The coordinates of the trees will not coincide with each other.

Output

For each test case, please output one number rounded to 2 digits after the decimal point representing the area of the smallest region. Or output "Impossible"(without quotations), if it do not exists such a region.

Sample Input

1 4 -1.00 0.00 0.00 -3.00 2.00 0.00 2.00 2.00

Sample Output

2.00

____

水题,直接枚举就可过。。

忘了用EPS 浮点数误差有问题

还有就是卡了一下输入,一开始判断n<3直接就CONTINUE了,这样接下来其他数据会出错。

代码如下:

#include<cstdio>

#include<algorithm>

#include<cmath>

#include<iostream>

using namespace std ;

#define N 110

#define eps 1e-8

struct

{

       doublex,y;

} array[N];

double area( double x1 , double y1 , doublex2 , double y2 ,double x3 , double y3 )

{

       returnfabs( 0.5 * ( x1*y2+x3*y1+x2*y3-x3*y2-x1*y3-x2*y1) ) ;

}

int main()

{

       intt ;

       cin>> t ;

       for(int i = 1 ; i<= t ; i++)

              {

                     intn ;

                     cin>> n ;

                     for(int i = 1 ; i<= n ; i++)

                            cin>> array[i].x >> array[i].y;

                     if(n < 3 )

                            {

                                   cout<<"Impossible" << endl ;

                                   continue;

                            }

                     doublemin = 99999999;

                     intflag = 1;

                     for(int i = 1 ; i <=n; i++)

                            {

                                   for(int j = i+1 ; j<=n ; j++)

                                          {

                                                 for(int k = j+1 ; k<= n; k++)

                                                        {

                                                               doubletemp =  area( array[i].x , array[i].y ,array[j].x,array[j].y,array[k].x,array[k].y) ;

                                                               if(fabs(temp) >= eps && temp <= min)

                                                                      {

                                                                             min= temp ;

                                                                             flag= 0 ;

                                                                      }

                                                        }

                                          }

                            }

                     if(flag == 0 )

                            printf("%.2lf\n",min);

                     else

                            cout<<"Impossible" << endl ;

              }

       return0 ;

}

HDU Herding的更多相关文章

  1. hdu 4709:Herding(叉积求三角形面积+枚举)

    Herding Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

  2. HDU 4709:Herding

    Herding Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  3. hdu - 4709 - Herding

    题意:给出N个点的坐标,从中取些点来组成一个多边形,求这个多边形的最小面积,组不成多边形的输出"Impossible"(测试组数 T <= 25, 1 <= N < ...

  4. HDU 4709 Herding (枚举)

    Herding Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

  5. hdu 4709 Herding hdu 2013 热身赛

    题意:给出笛卡尔坐标系上 n 个点,n不大于100,求出这些点中能围出的最小面积. 可以肯定的是三个点围成的面积是最小的,然后就暴力枚举,计算任意三点围成的面积.刚开始是求出三边的长,然后求面积,运算 ...

  6. HDU 4709 Herding 几何题解

    求全部点组成的三角形最小的面积,0除外. 本题就枚举全部能够组成的三角形,然后保存最小的就是答案了.由于数据量非常少. 复习一下怎样求三角形面积.最简便的方法就是向量叉乘的知识了. 并且是二维向量叉乘 ...

  7. 【Herding HDU - 4709 】【数学(利用叉乘计算三角形面积)】

    题意:给出n个点的坐标,问取出其中任意点围成的区域的最小值! 很明显,找到一个合适的三角形即可. #include<iostream> #include<cstdio> #in ...

  8. Herding(hdu4709)三点运用行列式求面积

    Herding Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  9. 学习数论 HDU 4709

    经过杭师大校赛的打击,明白了数学知识的重要性 开始学习数论,开始找题练手 Herding HDU - 4709 Little John is herding his father's cattles. ...

随机推荐

  1. 第一百三十三节,JavaScript,封装库--弹出登录框

    JavaScript,封装库--弹出登录框 封装库,增加了两个方法 yuan_su_ju_zhong()方法,将获取到的区块元素居中到页面,chuang_kou_shi_jian()方法,浏览器窗口事 ...

  2. System.InvalidOperationException: 找到多个与名为“Home”的控制器匹配的类型。

    一,当项目中存在多个网站报错,而不是新增Area出现这个错误时.应该在RouteConfig这样改: using System; using System.Collections.Generic; u ...

  3. iOS 让UIButton根据文字内容自动计算宽高

    Xcode自带的UIButton控件是没有办法根据文字内容计算自身的宽和高的,下面演示一下问题, 我用代码方式创建一个UIButton,并且设置了一些属性,下面看一下效果图 一切都是这么的美好,跟我们 ...

  4. TCP的滑动窗口机制【转】

    原文链接:http://www.cnblogs.com/luoquan/p/4886345.html      TCP这个协议是网络中使用的比较广泛,他是一个面向连接的可靠的传输协议.既然是一个可靠的 ...

  5. java中常遇到的问题

    一.乱码问题 =========================================================================================== 方 ...

  6. 在Windows上创建同样的Linux操作环境

    在之前的文章中,介绍了我在GNU/Linux图形界面环境下所使用的工具集合.其基本目的是在保证占用最少系统资源的条件下,将电脑操作效率推向极致.这样的工具组合尤如瑞士军刀一般,简洁.高效.功能全面.与 ...

  7. php dday1... web服务器的搭建 数据库的安装....

  8. 敏捷开发(五)- 框架SCRUM内容

    本文主要是为了检测你对SCRUM的了解和使用程度,通过本文你可以检测一下     1.你们的SCRUM项目中各个角色是否合格,    2.SCRUM上面需要的会议是否有遗留,会议过程是否正确    3 ...

  9. Mac OS启动服务优化高级篇(launchd tuning)

    Mac下的启动服务主要有三个地方可配置:1,系统偏好设置->帐户->登陆项2,/System/Library/StartupItems 和 /Library/StartupItems/3, ...

  10. 无线hacking系统—wifislax

    简介 官方中文网站: http://wifislax.cn/ WiFiSlax 是在Slax基础上定制出来的,由西班牙开发.它包含了各种各样的安全和诊断工具.该发行主要的成名原因是把各种各样的非官方网 ...