• 洛谷P1227 [JSOI2008]完美的对称


    洛谷P1227 [JSOI2008]完美的对称 

    #include <bits/stdc++.h> 
    #define For(i,j,k) for(int i=j;i<=k;i++)
    using namespace std ; 
    
    const int N = 20011 ; 
    const double eps = 1e-8 ; 
    struct node{
        double x,y ; 
    }a[N];
    node ans,tmp ; 
    double ansx,ansy ; 
    int n,mid ; 
    
    inline int read() 
    {
        int x = 0 , f = 1 ; 
        char ch = getchar() ; 
        while(ch<'0'||ch>'9') { if(ch=='-') f = -1 ; ch = getchar() ; } 
        while(ch>='0'&&ch<='9') { x=x * 10 + ch-48 ; ch = getchar() ; } 
        return x * f ; 
    }
    
    inline bool cmp(node a,node b) 
    {
        if(fabs(a.x - b.x) > eps) return a.x < b.x ; 
        return a.y < b.y ; 
    }
    
    inline void init() 
    {
        n = read() ; 
        For(i,1,n) 
            scanf("%lf%lf",&a[ i ].x,&a[ i ].y) ; 
    }
    
    inline void work() 
    {
        mid = n / 2 ; 
        sort(a+1,a+n+1,cmp) ; 
        ans.x = ( a[ 1 ].x + a[ n ].x ) / 2 ; 
        ans.y = ( a[ 1 ].y + a[ n ].y ) / 2 ;   
        For(i,2,mid) {
            tmp.x = ( a[ i ].x + a[ n-i+1 ].x ) / 2 ; 
            tmp.y = ( a[ i ].y + a[ n-i+1 ].y ) / 2 ; 
            if( fabs( ans.x - tmp.x ) > eps || fabs( ans.y - tmp.y > eps ) ) {
                printf("This is a dangerous situation!") ; 
                exit( 0 ) ; 
            }
        }
        printf("V.I.P. should stay at (%.1lf,%.1lf).",ans.x,ans.y) ; 
    }
    
    int main() 
    {
        init() ; 
        work() ; 
        return 0 ; 
    }
  • 相关阅读:
    python CreateUniqueName()创建唯一的名字
    node 创建静态服务器并自动打开浏览器
    基于jQuery 的插件开发
    Fetch
    纯css 来实现下拉菜单
    javascript模板引擎之
    jquery jsonp 跨域
    数据库增删改查
    Promise
    Vue.js
  • 原文地址:https://www.cnblogs.com/third2333/p/7283377.html
Copyright © 2020-2023  润新知