hihoCoder 1227 The Cats' Feeding Spots(水)
来源:互联网 发布:ibm云计算平台 编辑:程序博客网 时间:2024/04/30 13:59
题目链接:hihoCoder 1227 The Cats’ Feeding Spots
代码
#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const int maxn = 105;const int inf = 0x3f3f3f3f;int M, N;double X[maxn], Y[maxn], D[maxn][maxn];double dis(double x, double y) { return sqrt(x*x + y*y);}int main () { int cas; scanf("%d", &cas); for (int kcas = 1; kcas <= cas; kcas++) { scanf("%d%d", &M, &N); for (int i = 1; i <= M; i++) { scanf("%lf%lf", &X[i], &Y[i]); for (int j = 1; j <= i; j++) D[i][j] = D[j][i] = dis(X[i]-X[j], Y[i]-Y[j]); } int ans = inf; for (int i = 1; i <= M; i++) { sort(D[i] + 1, D[i] + 1 + M); int r = ceil(D[i][N]); for (int k = 0; k < 2; k++) { int c = 0, flag = 1; for (int j = 1; j <= M && flag; j++) { if (fabs(D[i][j] - r) < 1e-6) flag = 0; if (D[i][j] < r) c++; } if (flag && c == N) { ans = min(ans, r); } r++; } } if (ans == inf) ans = -1; printf("%d\n", ans); } return 0;}
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
- shiro安全框架扩展教程--如何扩展实现集中式session管理(redis,memcached等)
- jqXHR对象
- php的RSA加密解密算法
- “钱三篇”后续之中国利率
- Android 最火的快速开发框架XUtils
- hihoCoder 1227 The Cats' Feeding Spots(水)
- 5.Python补充_字符串格式化 (%操作符)
- jQuery.when(deferreds)
- ContextLoaderListener使用
- hihoCoder 1228 Mission Impossible 6(模拟)
- Cornerstone - 1
- C# Dictionary 的几种遍历方法
- 乘法快速幂
- c++项目 ——公司管理系统