zoukankan      html  css  js  c++  java
  • hihocode_1227——ceil——The Cats' Feeding Spots

    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
    ", ans);
        }
        return 0;
    }
    

      

  • 相关阅读:
    稠密光流
    分水岭分割
    Haar小波分析
    内积空间
    矩阵LU分解
    opencv笔记---contours
    Deformable Templates For Eye Detection
    最小二乘法
    字符集及编码
    层次聚类
  • 原文地址:https://www.cnblogs.com/zero-begin/p/4826222.html
Copyright © 2011-2022 走看看