2015北京网络赛A题The Cats' Feeding Spots
题意:给你一百个点,找个以这些点为中心的最小的圆,使得这个圆恰好包含了n个点,而且这个圆的边界上并没有点
解题思路:暴力枚举每个点,求出每个点到其他点的距离,取第n大的点,判断一下。
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<memory.h>
using namespace std;
const int MAXN=;
const double eps=1e-;
const int inf=0x3f3f3f3f; struct point
{
double x,y;
}node[]; int n,m,T;
double d[][]; double dis(point a,point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
} int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&m,&n);
memset(d,,sizeof(d));
for(int i=;i<m;i++)
{
scanf("%lf%lf",&node[i].x,&node[i].y);
}
if(n>m)
{
printf("-1\n");
continue;
}
int ans=inf;
for(int i=;i<m;i++)
{
for(int j=;j<m;j++)
{
d[i][j]=dis(node[i],node[j]);
}
}
for(int i=;i<m;i++)
{
sort(d[i],d[i]+m);
int p=(int)ceil(d[i][n-]+eps);
if(d[i][n]-p>eps||n==m)
ans=min(ans,p);
}
if(ans==inf) ans=-;
printf("%d\n",ans);
}
return ;
}
2015北京网络赛A题The Cats' Feeding Spots的更多相关文章
- 2015北京网络赛 A题 The Cats' Feeding Spots 暴力
The Cats' Feeding Spots Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/contest/acm ...
- 2015北京网络赛 G题 Boxes bfs
Boxes Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/contest/acmicpc2015beijingonl ...
- 2015北京网络赛 H题 Fractal 找规律
Fractal Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/contest/acmicpc2015beijingo ...
- hihocoder 1236(2015北京网络赛 J题) 分块bitset乱搞题
题目大意: 每个人有五门课成绩,初始给定一部分学生的成绩,然后每次询问给出一个学生的成绩,希望知道在给定的一堆学生的成绩比这个学生每门都低或者相等的人数 因为强行要求在线查询,所以题目要求,每次当前给 ...
- 2015北京网络赛B题 Mission Impossible 6
借用大牛的一张图片:模拟 #include<cstdio> #include<cmath> #include<cstring> #include<algori ...
- 2015 北京网络赛 C Protecting Homeless Cats hihoCoder 1229 树状数组
题意:求在平面上 任意两点连线,原点到这个点的距离小于d的点对有多少个,n=200000; 解: 以原点为圆心做一个半径为d的圆,我们知道圆内的点和园内以外的点的连线都是小于d的还有,圆内和园内的点联 ...
- 2015北京网络赛 Couple Trees 倍增算法
2015北京网络赛 Couple Trees 题意:两棵树,求不同树上两个节点的最近公共祖先 思路:比赛时看过的队伍不是很多,没有仔细想.今天补题才发现有个 倍增算法,自己竟然不知道. 解法来自 q ...
- 2015北京网络赛 D-The Celebration of Rabbits 动归+FWT
2015北京网络赛 D-The Celebration of Rabbits 题意: 给定四个正整数n, m, L, R (1≤n,m,L,R≤1000). 设a为一个长度为2n+1的序列. 设f(x ...
- 2015北京网络赛 J Scores bitset+分块
2015北京网络赛 J Scores 题意:50000组5维数据,50000个询问,问有多少组每一维都不大于询问的数据 思路:赛时没有思路,后来看解题报告也因为智商太低看了半天看不懂.bitset之前 ...
随机推荐
- Good Bye 2015B
Problem B:http://codeforces.com/contest/611/problem/B B. New Year and Old Property 题意:问输入的年份a到b中转化为二 ...
- spoj 62
看了题解 自己好水 ...... #include <cstdio> #include <cstdlib> struct node { int x,y; }; node ...
- eclipse 安装配置maven
1.安装maven 插件 从eclipse 3.7(indigo)之后,m2e 插件已host到eclipse.org 站点下: Since Eclipse 3.7 (Indigo), m2e is ...
- MVC 导出PDF
http://www.simple-talk.com/dotnet/asp.net/asp.net-mvc-action-results-and-pdf-content/ http://www.sub ...
- Java Socket实战之一 单线程通信
本文地址:http://blog.csdn.net/kongxx/article/details/7259436 现在做Java直接使用Socket的情况是越来越少,因为有很多的选择可选,比如说可以用 ...
- Android:控件GridView的使用
如果是列表(单列多行形式)的使用ListView,如果是多行多列网状形式的优先使用GridView. <?xml version="1.0" encoding="u ...
- WAMP 80端口被Microsoft-HTTPAPI/2.0占用的解决办法
WAMP 80端口被Microsoft-HTTPAPI/2.0占用的解决办法 - likebeta - 博客园 http://www.cnblogs.com/likebeta/archive/2012 ...
- RTL 与 technology schematic的区别,包含概念与实例
2013-06-25 16:40:45 下面是xilinx官网上的问答贴: http://china.xilinx.com/support/answers/41500.htm#solution The ...
- Git教程(5)常用技巧之本地分支
http://git-scm.com/book/zh/v2/Git-%E5%88%86%E6%94%AF-%E5%88%86%E6%94%AF%E7%AE%80%E4%BB%8B 基础 Git 研发组 ...
- bzoj4511: [Usaco2016 Jan]Subsequences Summing to Sevens
前缀和. 设f[i]为前缀和%7=i的第一个点.那么答案就是max(i-f[s[i]%7])了. #include<cstdio> #include<algorithm> #i ...