hihoCoder 1227 The Cats' Feeding Spots 2015北京赛区网络赛
来源:互联网 发布:张大千 敦煌破坏 知乎 编辑:程序博客网 时间:2024/04/30 08:06
题意:t组测试数据
有n个点,先要求以其中的一个点为圆心画圆将m个点包围起来。求半径最小是多少,点不能在圆上。(坐标可以为小数)
分析:水题,由于数据比较小,直接枚举以每一个点为圆心的情况就可以了。注意半径要为整数。
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cstdlib>//#pragma comment(linker, "/STACK:1024000000,1024000000")#include <string>#include <cmath>using namespace std;struct node{ double x,y;}A[105];double a[105][105];bool cmp(node a,node b){ if(a.x==b.x)return a.y<b.y; return a.x<b.x;}int main(){ int t,m,n; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&m); for(int i = 0 ; i < n ; i++) { scanf("%lf%lf",&A[i].x,&A[i].y); } sort(A,A+n,cmp); for(int i = 0 ; i < n ; i++) { for(int j = 0 ; j < n ; j++) { if(i==j)a[i][j]=0; else a[i][j]=a[j][i]=sqrt((A[i].x-A[j].x)*(A[i].x-A[j].x)+(A[i].y-A[j].y)*(A[i].y-A[j].y)); //cout<<a[i][j]<<endl; } } int num = 1000005; int ans = 0; int b,c; for(int i = 0 ; i < n ; i++) { sort(a[i],a[i]+n);// for(int j = 0 ; j < n ; j++)// {// cout<<a[i][j]<<" ";// }// cout<<endl; b = a[i][m-1]; if(m!=n&&b+1>=a[i][m])c=-1; else { ans=1; c=b+1; } if(c!=-1&&c<=num)num=c; } if(ans==0)printf("-1\n"); else printf("%d\n",num); } return 0;}
0 0
- hihoCoder 1227 The Cats' Feeding Spots 2015北京赛区网络赛
- hihocoder #1227 : The Cats' Feeding Spots 北京赛区(2015)网络赛 (暴力枚举)
- 北京赛区(2015)网络赛The Cats' Feeding Spots
- hihoCoder 1227 The Cats' Feeding Spots(暴力)——ACM-ICPC国际大学生程序设计竞赛北京赛区(2015)网络赛
- hihoCoder 1227 The Cats' Feeding Spots && ACM-ICPC国际大学生程序设计竞赛北京赛区(2015)网络赛
- 1001 The Cats' Feeding Spots (2015年北京赛区网络赛A题)
- 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
- hihoCoder1227 The Cats' Feeding Spots 二分
- hihoCoder1227 The Cats' Feeding Spots【暴力】
- hihoCoder 1236 Scores(2015北京赛区网络赛)
- hihoCoder 1231 Border Length(北京赛区(2015)网络赛 E)
- Cats and Fish2017北京赛区网络同步赛
- Cats and Fish 2017ACM-ICPC北京赛区/hihoCoder 1631
- 关于SO_LINGER 设置
- 三元运算符
- Java(2)--单例模式
- POJ - 1375
- ConcurrentHashMap实现解析
- hihoCoder 1227 The Cats' Feeding Spots 2015北京赛区网络赛
- 《大话数据结构》之单链表
- 备注:smush.it 接口
- C语言strcpy,strncpy的用法
- 对于Windows传感器开发的一些感悟
- 习奥会前奏:第八届中美互联网论坛
- Point To Segment Distance Used In Creo / Proe
- (绝对有用)iOS获取UUID,并使用keychain存储
- GLib介绍与使用