hihoCoder #1227 : The Cats' Feeding Spots
来源:互联网 发布:中国人民银行 知乎 编辑:程序博客网 时间:2024/04/30 13:41
原题链接:
http://hihocoder.com/problemset/problem/1227
题目大意:
T组测试数据。
m个点,以任意一点为圆心求一个最小半径r将n个点圈起来。(边界上不允许有点)
代码如下:
#include<iostream>#include<cstdio>#include<cmath>#include<utility>#include<algorithm>;using namespace std;const int MAXN=1000+10;pair<double,double>p[MAXN];double r[MAXN];int main(){int T;scanf("%d",&T);while(T--){int n,m;int ans=MAXN;scanf("%d%d",&m,&n);for(int i=0;i<m;i++){scanf("%lf%lf",&p[i].first,&p[i].second);}for(int i=0;i<m;i++){double R;for(int j=0;j<m;j++)r[j]=sqrt((p[i].first-p[j].first)*(p[i].first-p[j].first)+(p[i].second-p[j].second)*(p[i].second-p[j].second));sort(r,r+m);R=ceil(r[n-1]);R=R==r[n-1]?R+1:R;//处理边界上点if(m!=n&&R >= r[n]) continue;//不能超过n个点if(R<ans)ans=R;}if(ans==MAXN){cout<<-1<<endl;continue;}cout<<ans<<endl;}}
0 0
- hihoCoder #1227 : The Cats' Feeding Spots
- hihoCoder 1227 The Cats' Feeding Spots(水)
- hihoCoder 1227 The Cats' Feeding Spots
- hihocoder #1227 : The Cats' Feeding Spots(枚举)
- 【HIHOCODER】The Cats' Feeding Spots
- hiho1227--The Cats' Feeding Spots
- hihoCoder 1227 The Cats' Feeding Spots 2015北京赛区网络赛
- hihocoder #1227 : The Cats' Feeding Spots 北京赛区(2015)网络赛 (暴力枚举)
- hihoCoder 1227 The Cats' Feeding Spots(暴力)——ACM-ICPC国际大学生程序设计竞赛北京赛区(2015)网络赛
- hihoCoder 1227 The Cats' Feeding Spots && ACM-ICPC国际大学生程序设计竞赛北京赛区(2015)网络赛
- hihoCoder1227 The Cats' Feeding Spots 二分
- hihoCoder1227 The Cats' Feeding Spots【暴力】
- 北京赛区(2015)网络赛The Cats' Feeding Spots
- 1001 The Cats' Feeding Spots (2015年北京赛区网络赛A题)
- Cats and Fish HihoCoder
- hihocoder 1631 Cats and Fish
- Hihocoder #1631 : Cats and Fish 模拟
- Cats and Fish 2017ACM-ICPC北京赛区/hihoCoder 1631
- 选项菜单之主菜单
- Java读取Excel
- 云计算常用的加密方法
- 快速排序java实现
- EL表达式
- hihoCoder #1227 : The Cats' Feeding Spots
- EPOLL在ET模式下会被触发多次么?
- Intent中的四个重要属性——Action、Data、Category、Extras
- android之ListFragment
- poj3294Life Forms
- LeetCode 题解(222) : Binary Tree Level Order Traversal II
- c#中如何截取Windows消息来触发自定义事件
- JS 跨域资源共享 -- Ajax CORS / img ping / jsonp
- LCD错误