HDU 4709:Herding
Herding
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2418 Accepted Submission(s): 705
(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.
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.
1
4
-1.00 0.00
0.00 -3.00
2.00 0.00
2.00 2.00
2.00
迷失在幽谷中的鸟儿,独自飞翔在这偌大的天地间,却不知自己该飞往何方……
题意:给出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的更多相关文章
- hdu 4709:Herding(叉积求三角形面积+枚举)
Herding Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- 学习数论 HDU 4709
经过杭师大校赛的打击,明白了数学知识的重要性 开始学习数论,开始找题练手 Herding HDU - 4709 Little John is herding his father's cattles. ...
- HDU - 6409:没有兄弟的舞会(数学+思维)
链接:HDU - 6409:没有兄弟的舞会 题意: 题解: 求出最大的 l[i] 的最大值 L 和 r[i] 的最大值 R,那么 h 一定在 [L, R] 中.枚举每一个最大值,那么每一个区间的对于答 ...
- 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 ...
- hdu - 4709 - Herding
题意:给出N个点的坐标,从中取些点来组成一个多边形,求这个多边形的最小面积,组不成多边形的输出"Impossible"(测试组数 T <= 25, 1 <= N < ...
- hdu 4709 Herding hdu 2013 热身赛
题意:给出笛卡尔坐标系上 n 个点,n不大于100,求出这些点中能围出的最小面积. 可以肯定的是三个点围成的面积是最小的,然后就暴力枚举,计算任意三点围成的面积.刚开始是求出三边的长,然后求面积,运算 ...
- HDU 4709 Herding 几何题解
求全部点组成的三角形最小的面积,0除外. 本题就枚举全部能够组成的三角形,然后保存最小的就是答案了.由于数据量非常少. 复习一下怎样求三角形面积.最简便的方法就是向量叉乘的知识了. 并且是二维向量叉乘 ...
- HDU 4709 Herding (枚举)
Herding Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- 【Herding HDU - 4709 】【数学(利用叉乘计算三角形面积)】
题意:给出n个点的坐标,问取出其中任意点围成的区域的最小值! 很明显,找到一个合适的三角形即可. #include<iostream> #include<cstdio> #in ...
随机推荐
- Oracle 监听器日志文件过大导致监听异常
Oracle 监听器日志文件过大导致监听异常 db版本:11.2.0.1 os版本:windows2008 现象: 应用异常,无法连接数据库.登陆数据库服务器,查看监听已经断掉.尝试重启监听,重启失败 ...
- 基于DES算法加密的防撞库密码系统项目总结
项目内容:基于DES算法加密的防撞库密码系统 小组名:zqhzkzkj 目标:1.对用户输入的8位字符进行DES加密,要求用户输入8位密钥 2.对于不同的网站,不同的用户名生成不同的密码 小组成员:周 ...
- From Disk partition to PostgreSQL installation
From Disk partition to PostgreSQLinstallation [root@compute mnt]# fdisk /dev/sdb Welcome to fdisk (u ...
- html 鼠标移入标签 显示小手指
<div style="width: 200px; height: 200px; background: red; cursor: pointer;"></div ...
- c++之路进阶——bzoj3343(教主的魔法)
F.A.Qs Home Discuss ProblemSet Status Ranklist Contest ModifyUser gryz2016 Logout 捐赠本站 Notice:由于本OJ ...
- 。。。mkdir与mkdirs的区别。。。
一直想知道他俩的区别,也一直忘记了,知道今天才没有放过这个机会! mkdir的用法是正创建一层目录,比如说在C盘下创建aa文件夹,c:\aa,这个aa是不存在的,这个话,是可以用mkdir创建的,但是 ...
- demo03linearlayoutdemo;
package com.example.demo03linearlayoutdemo; import android.os.Bundle; import android.app.Activity; i ...
- 前端构建工具gulp入门
本文假设你之前没有用过任何任务脚本(task runner)和命令行工具,一步步教你上手Gulp.不要怕,它其实很简单,我会分为五步向你介绍gulp并帮助你完成一些惊人的事情.那就直接开始吧. 第一步 ...
- mongo自带测试
benchrun > res = benchRun({ ops:[{ ns:"test.foo", op:"insert", doc:{y:{,]}} } ...
- 夺命雷公狗---node.js---13之Buffer的转换
其实Buffer也是一种数据结构的东西,但实际中用得并不多,我们只需要知道常用的转换方法即可: /** * Created by leigood on 2016/8/30. */ var str = ...