枚举所有可能的半径,然后将所有满足这个半径的点按角度(与x轴正半轴的夹角)排序。 然后一遍扫描求出在这个半径下选k个点所需的最小面积 。

思路还是比较简单,实现略有些繁琐。

要先将点的坐标转换为角度。 如果用斜率的方法的话有些繁琐。

Fire-Control System

Time Limit: 12000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2047    Accepted Submission(s): 350

Problem Description
A new mighty weapon has just been developed, which is so powerful that it can attack a sector of indefinite size, as long as the center of the circle containing the sector is the location of the weapon. We are interested in developing a fire-control system that calculates firing-solutions automatically.
The following example gives an example of a firing solution:
Figure 1

Here the firing region is the sector "ABC" that covers six points: A, B, C, D, E, H. You may further assume that the weapon is always located at point (0, 0), no targets will be on the point (0, 0) and the coordinates of the targets will be distinct.
A firing solution is called effective if and only if it covers a minimum of K points
out of N given points (targets) on the two-dimensional Cartesian plane. Furthermore,since the cost of a particular fire solution is in direct proportion to the size of the area it covers, a firing could be quite costly; thus we are only interested in the optimal firing solution with the minimum cost.
 
Input
There are multiple test cases in the input file.
Each test case starts with two non-negative integers, N and K
(1 ≤ N ≤ 5000 , K ≤ N ), followed by N lines each containing two integers, X, and Y, describing the distinct location of one target. It is guaranteed that the absolute value of any integer does not exceed 1000.
Two successive test cases are separated by a blank line. A case with N = 0 and K = 0 indicates the end of the input file, and should not be processed by your program.
 
Output
For each test case, please print the required size (to two decimal places), in the
format as indicated in the sample output.
 
Sample Input
3 1
0 1
1 0
-5 -6
3 2
0 2
2 0
-5 -6
0 0
 
Sample Output
Case #1: 0.00
Case #2: 3.14
 
Source
 
Recommend
lcy
 
#include <iostream>
#include <stdio.h>
#include <queue>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;
#define N 100100
#define PI (2*asin(1.0)) struct node
{
int x,y;
double r;//表示半径
double du;//用来表示角度
}g[N]; int n,k;
double g1[N]; int cmp(node t,node t1)
{
return t.du<t1.du;
} double que[*N]; double mabs(double x)
{
if(x<) return -x;
return x;
} int main()
{
//freopen("//home//ismdeep//xianchang1//in","r",stdin);
int tt=;
double pi=PI;
while(scanf("%d%d",&n,&k)&&(n+k))
{ for(int i=;i<=n;i++)
{
scanf("%d%d",&g[i].x,&g[i].y);
g[i].r=sqrt((double)g[i].x*g[i].x+g[i].y*g[i].y);
g1[i]=g[i].r; double tmp; if(mabs(g[i].x-)<1e-)
{
if(g[i].y>) tmp=90.0;
else tmp=270.0;
}
else
{
tmp=((double)g[i].y/(double)g[i].x); //将这个点的斜率求出来
if(mabs(g[i].y-)<1e-)
{
if(g[i].x>) tmp=0.0;
else tmp=180.0;
}
else
{
tmp=atan(tmp);//求出角度
tmp=(180.0/PI)*tmp;
if(g[i].y*g[i].x > &&g[i].y<)
tmp+=180.0;
if(g[i].y*g[i].x<)
{
tmp*=-;
if(g[i].x<)
tmp=180.0-tmp;
else
{
tmp=-tmp;
}
} }
}
g[i].du=tmp;
}
// 角度求好了
if(k==)
{
printf("Case #%d: 0.00\n",tt++);
continue;
}
//sort(g1+1,g1+n+1); //半径从小到大来搞一搞啊
sort(g+,g++n,cmp); double mi=; for(int ii=;ii<=n;ii++)
{
double key=g1[ii]; //表示固定的半径
int flag=; for(int i=;i<=n;i++)//提前
{
if(g[i].r <= key+1e-)
{
que[flag++]=g[i].du;
}
} for(int i=;i<flag;i++)
{
que[flag+i] = que[i]+360.0;
} if(flag<k) continue; for(int i=;i<flag;i++)
{
double tmp=que[i];
int tt=i+k-;
double tmp1=que[tt];
tmp=tmp1-tmp; tmp=(tmp/(360.0))*PI*key*key; mi=min(tmp,mi);
}
} printf("Case #%d: ",tt++); printf("%.2lf\n",mi);
}
return ;
}

hdu2469(计算几何)的更多相关文章

  1. ACM/ICPC 之 计算几何入门-叉积-to left test(POJ2318-POJ2398)

    POJ2318 本题需要运用to left test不断判断点处于哪个分区,并统计分区的点个数(保证点不在边界和界外),用来做叉积入门题很合适 //计算几何-叉积入门题 //Time:157Ms Me ...

  2. HDU 2202 计算几何

    最大三角形 Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  3. ACM 计算几何中的精度问题(转)

    http://www.cnblogs.com/acsmile/archive/2011/05/09/2040918.html 计算几何头疼的地方一般在于代码量大和精度问题,代码量问题只要平时注意积累模 ...

  4. hdu 2393:Higher Math(计算几何,水题)

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

  5. sdut 2603:Rescue The Princess(第四届山东省省赛原题,计算几何,向量旋转 + 向量交点)

    Rescue The Princess Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Several days ago, a b ...

  6. [知识点]计算几何I——基础知识与多边形面积

    // 此博文为迁移而来,写于2015年4月9日,不代表本人现在的观点与看法.原始地址:http://blog.sina.com.cn/s/blog_6022c4720102vxaq.html 1.前言 ...

  7. POJ 1106 Transmitters(计算几何)

    题目链接 切计算几何,感觉计算几何的算法还不熟.此题,枚举线段和圆点的直线,平分一个圆 #include <iostream> #include <cstring> #incl ...

  8. TYVJ计算几何

    今天讲了计算几何,发几道水水的tyvj上的题解... 计算几何好难啊!@Mrs.General....怎么办.... 这几道题都是在省选之前做的,所以前面的Point运算啊,dcmp啊,什么什么的,基 ...

  9. 计算几何 平面最近点对 nlogn分治算法 求平面中距离最近的两点

    平面最近点对,即平面中距离最近的两点 分治算法: int SOLVE(int left,int right)//求解点集中区间[left,right]中的最近点对 { double ans; //an ...

随机推荐

  1. jenkins部署前端node项目实例

    Jenkins 分发文件用到rsync命令   在 /etc/passwd中 修改 jenkins 为 /bin/bash jenkins:x:494:494:Jenkins Automation S ...

  2. Sphinx-安装和配置

    本例是在Linux下, 环境 CentOS6.5 + PHP5.6.8 + MySQL5.6.13 + Sphinx2.3.1-beta 到官网下载对应环境的安装包, 按照官方文档指定步骤进行安装 第 ...

  3. PHP-PHP程序员的技术成长规划(By黑夜路人)

    按照了解的很多PHP/LNMP程序员的发展轨迹,结合个人经验体会,抽象出很多程序员对未来的迷漫,特别对技术学习的盲目和慌乱,简单梳理了这个每个阶段PHP程序员的技术要求,来帮助很多PHP程序做对照设定 ...

  4. Android App补丁更新

    上一周比较忙,忙的不可开交,写的文章也就两篇,在此希望大家见谅.这周呢,突然闲下来了,有时间了,就重构了下代码,捣鼓点前卫的技术,沉淀沉淀.所以呢,今天就分享下这几天研究的东西. 移动互联网主打的就是 ...

  5. 体验了把做HR的感觉,上午看了40份简历,说说感受

    原文链接:http://huachichi.info/2013/06/26/experience-of-being-a-hr/   这两天准备从IBM离职,不要问我为什么要在这么bug的时间离职,总之 ...

  6. Docker运行报Cannot connect to the Docker daemon错误

    核心问题所在:权限不足 操作docker命令提示:Cannot connect to the Docker daemon 请切换管理员权限,root权限,root安装的一般的用户访问会存在此问题.

  7. 使用struct与使用class初始化对象效率对比

    using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using S ...

  8. STM32的IO口灌入电流和输出驱动电流最大是多少?

    最大可以输出8mA,灌入20mA,但要保证所有进入芯片VDD的电流不能超过150mA,同样所有从VSS流出的电流也不能超过150mA. 详细请看STM32的数据手册中的相关内容. 例如,STM32F1 ...

  9. c语言中数组名和指针变量的区别

    编译器工作原理:在64位的计算机中,当创建一个指针变量时,计算机会为它分配8个字节的存储空间.但如果创建的是数组呢?计算机会为数组分配存储空间,但不会为数组变量分配任何空间,编译器仅在出现它的地方把它 ...

  10. Atitit.故障排除系列---NoClassDefFoundError  NoClassDefFoundError ClassNotFoundException

    Atitit.故障排除系列---NoClassDefFoundError  NoClassDefFoundError ClassNotFoundException 1. java.lang.Class ...