【HIHOCODER】The Cats' Feeding Spots
来源:互联网 发布:手机可以禁止安装软件 编辑:程序博客网 时间:2024/04/30 14:51
The Cats’ Feeding Spots
题目链接
- The Cats’ Feeding Spots
题目大意
给你n个点,现在要你选择一个半径为R的圆,圆心是某个点,然后这个圆中间需要包括n个点,而且在圆上不能有点。
题解
暴力
首先可以求出每个点距其他点的距离,然后枚举半径即可,复杂度
代码
#include <iostream>#include <cstring>#include <cstdio>#include <vector>#include <cmath>#include <algorithm>using namespace std;struct node{ double x,y;};node mp[205];int T,m,n;vector<double> v[205];int main(){ scanf("%d",&T); while (T--) { memset(mp,0,sizeof(mp)); int ans=0x7fffffff; for (int i=0;i<205;i++) v[i].clear(); scanf("%d%d",&m,&n); for (int i=0;i<m;i++) scanf("%lf%lf",&mp[i].x,&mp[i].y); for (int i=0;i<m-1;i++) for (int j=i+1;j<m;j++) { double l=sqrt( (mp[i].x-mp[j].x)*(mp[i].x-mp[j].x)+(mp[i].y-mp[j].y)*(mp[i].y-mp[j].y) ); v[i].push_back(l); v[j].push_back(l); } bool f=0; for (int i=0;i<m;i++) sort(v[i].begin(),v[i].end()); for (int i=0;i<m;i++) { int r=1,j=0; while (j<m-1) { while (r>v[i][j] && j<m-1) j++; if (j>=m-1) break; if (r==v[i][j]) { r++; continue;} if (j+1==n) ans=min(ans,r); r++; } if (n==m) ans=min(ans,r); } if (ans!=0x7fffffff) printf("%d\n",ans); else printf("-1\n"); } return 0;}
0 0
- 【HIHOCODER】The Cats' Feeding Spots
- hihoCoder #1227 : The Cats' Feeding Spots
- hihoCoder 1227 The Cats' Feeding Spots(水)
- hihoCoder 1227 The Cats' Feeding Spots
- hihocoder #1227 : The Cats' Feeding Spots(枚举)
- hiho1227--The Cats' Feeding Spots
- hihoCoder1227 The Cats' Feeding Spots 二分
- hihoCoder1227 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)网络赛
- 北京赛区(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
- eetcode_c++:链表:Swap Nodes in Pairs(024)
- B. Remainders Game
- Android小知识点积累
- UVA-10815 Andy's First Dictionary
- 树——找到二叉树中的最大二叉搜索树
- 【HIHOCODER】The Cats' Feeding Spots
- Hibernate 简单使用(三)一对一关联映射
- HTTP
- jzoj 1568. 【普及模拟】石子游戏 解题报告
- 运算符和表达式
- 随机森林算法的源码分析(一)
- Android studio libpng error: Not a PNG file
- 指针数组 数组指针 指针函数 函数指针
- UVA10916Factstone Benchmark