Herding

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 2418    Accepted Submission(s): 705

Problem 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
 
Source
 

迷失在幽谷中的鸟儿,独自飞翔在这偌大的天地间,却不知自己该飞往何方……

题意:给出n个点的坐标,问取出其中任意点围成的区域的最小值!

这个当然是三角形咯!既然给定了点的坐标,直接使用两向量叉乘除以二便可以解决!


#include<stdio.h>
#include<math.h>
#include<iostream>
using namespace std;
#include<string.h>
struct ab
{
double x,y;
} ab[105];
double solve(int i,int j,int k)
{
double a=ab[i].x-ab[k].x;
double b=ab[j].y-ab[k].y;
double c=ab[i].y-ab[k].y;
double d=ab[j].x-ab[k].x;
return fabs(a*b-c*d)/2.0;
}
int main()
{
int N;
cin>>N;
while(N--)
{
int n;
cin>>n;
for(int i=0; i<n; i++)
cin>>ab[i].x>>ab[i].y;
double minn=0xffffffff;
for(int i=0; i<n; i++)
for(int j=i+1; j<n; j++)
for(int k=j+1; k<n; k++)
{
double t=solve(i,j,k);
t=fabs(t);
if(t<=1e-7)continue;
minn=minn>t?t:minn;
}
if(minn==0xffffffff)printf("Impossible\n");
else printf("%.2lf\n",minn);
}
return 0;
}

HDU 4709: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 HDU - 4709 Little John is herding his father's cattles. ...

  3. HDU - 6409:没有兄弟的舞会(数学+思维)

    链接:HDU - 6409:没有兄弟的舞会 题意: 题解: 求出最大的 l[i] 的最大值 L 和 r[i] 的最大值 R,那么 h 一定在 [L, R] 中.枚举每一个最大值,那么每一个区间的对于答 ...

  4. POJ 3321:Apple Tree + HDU 3887:Counting Offspring(DFS序+树状数组)

    http://poj.org/problem?id=3321 http://acm.hdu.edu.cn/showproblem.php?pid=3887 POJ 3321: 题意:给出一棵根节点为1 ...

  5. hdu - 4709 - Herding

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

  6. hdu 4709 Herding hdu 2013 热身赛

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

  7. HDU 4709 Herding 几何题解

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

  8. HDU 4709 Herding (枚举)

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

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

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

随机推荐

  1. docker offical docs:Working with Containers

    enough ---------------------------------------------------------------------------------- Working wi ...

  2. web app 自适应 弹性布局之rem

    关于rem,主要参考文档 1.腾讯ISUX (http://isux.tencent.com/web-app-rem.html) 2.http://www.w3cplus.com/css3/defin ...

  3. WebService 的一些基本概念

    一. 1.Endpoint http://www.ttdev.com/SimpleService 这个webservice全名就是所谓的"endpoint" 2.RPC type ...

  4. MFC架构

    MFC的六大关键技术: 1)MFC程序的初始化过程 2)消息映射 3)运行时类型识别(RTTI) 4)动态创建 5)永久保存 6)消息传递 一.MFC的初始化过程: MFC的架构组成: 1.要有CWi ...

  5. java 项目打包流程速记

    1.与资源库同步 2.[解决冲突] --可能没有这一步 3.合并标记 4.清除一下项目-- clean 5.打包: run As -->Maven install 6.去服务备份原包,下载服务 ...

  6. 组合逻辑的Glitch与时序逻辑的亚稳态

    竞争(Race):一个门的输入有两个及以上的变量发生变化时,由于各个输入的组合路径的延时不同,使得在门级输入的状态改变非同时. 冒险或险象(Hazard):竞争的结果,如毛刺Glitch. 相邻信号间 ...

  7. stdlib 头文件

    stdlib 头文件即standard library标准库头文件.stdlib.h里面定义了五种类型.一些宏和通用工具函数. 类型例如size_t.wchar_t.div_t.ldiv_t和lldi ...

  8. beta阶段事后诸葛亮会议

    项目名:约跑 组名:nice! 组长:李权 组员: 韩媛媛 于淼 刘芳芳 宫丽君 Beta Review会议 时间:2016.11.15 地点:冬华楼一楼大厅 会议内容: 约跑APP的Beta Rev ...

  9. 9. 星际争霸之php设计模式--代理模式

    题记==============================================================================本php设计模式专辑来源于博客(jymo ...

  10. Windows应用层网络模块扫盲

           说到Windows应用层网络通信不得不提winsock,winsock是工作在TCP/IP层的应用层(TCP/IP层分为主机到网络层[比特].网络互联层[数据帧].传输层[数据包].应用 ...