标签:
http://hihocoder.com/problemset/problem/1227
/************************************************ * Author :Powatr * Created Time :2015/9/21 14:46:41 * File Name :A.cpp ************************************************/ #include <cstdio> #include <algorithm> #include <iostream> #include <sstream> #include <cstring> #include <cmath> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <list> #include <map> #include <set> #include <bitset> #include <cstdlib> #include <ctime> using namespace std; #define lson l, mid, rt << 1 #define rson mid + 1, r, rt << 1 | 1 typedef long long ll; const int MAXN = 1e5 + 10; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; const double EPS = 1e-8; double x[110], y[110]; double d[11000]; int main(){ int T; scanf("%d", &T); while(T--){ int n, m; scanf("%d%d", &n, &m); for(int i = 1; i <= n; i++) scanf("%lf%lf", &x[i], &y[i]); int ans = INF; for(int i = 1; i <= n; i++){ int pos = 0; for(int j = 1; j <= n; j++){ d[++pos] = sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j])); } sort(d + 1, d + pos + 1); int temp = ceil(d[m] + EPS); if(n == m){ ans = min(ans, temp); } else { if(d[m+1] - temp > 0){ ans = min(ans, temp); } } } if(ans == INF) puts("-1"); else printf("%d\n", ans); } return 0; }
hihocode_1227——ceil——The Cats' Feeding Spots
标签:
原文地址:http://www.cnblogs.com/zero-begin/p/4826222.html