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之前 ...
随机推荐
- What are the advantages of logistic regression over decision trees?FAQ
What are the advantages of logistic regression over decision trees?FAQ The answer to "Should I ...
- 编写你的第一个 Django 程序 第1部分
原地址:http://django-chinese-docs.readthedocs.org/en/latest/intro/tutorial01.html 让我们通过例子来学习. 在本教程中,我们将 ...
- Hardwood Species
http://poj.org/problem?id=2418 #include<cstdio> #include<cstring> #include<string> ...
- DJANGO的ORM的Q查询作多字段外键的模糊查询样码
工作中用到的,存照一下. from django.db.models import Q if self.kwargs.has_key('search_pk'): search_pk = self.kw ...
- 一个批量转换jtl文件的shell
最近在项目中遇到了批量转换jmeter测试结果jtl的问题,整了一个脚本,记录如下: #bin/sh filelist=`ls jtl` # 将jtl目录的所有文件列表读取并存入变量 for file ...
- [Unity菜鸟] 摄像机视角控制
1. 摄像机预览物体 上下左右远近 把CameraFollow脚本赋给Camera,把要观察的对象赋给target using UnityEngine; using System.Collection ...
- C#基础精华04(文件流,文件操作,File、Directory、Path,Directory)
文件流 FileStream 可读可写 大文件 释放 StreamReader 读取 释放 StreamWriter 写入 释放 using 中释放 File 可读可写 小文件 操作文 ...
- Creating a web server in pure C(c/c++ 写web server)
一个简单的例子:https://github.com/fekberg/GoHttp 一个运行在windows上例子:http://www.adp-gmbh.ch/win/misc/webserver. ...
- Call to undefined function pg_
网上普遍的解决方案: 1.修改php.ini文件, 添加php_pgsql.dll扩展 2.如果是wamp这样类似的软件,可以直接通过图形化操作 这样操作后,大部分RD都是没有问的...但是为什么还提 ...
- 关于 mysqladmin
>mysqladmin 工具的使用格式: mysqladmin [option] command [command option] command ...... option 选项: -c nu ...