zoukankan      html  css  js  c++  java
  • 洛谷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 ; 
    }
  • 相关阅读:
    使用Fiddler抓包(手机端app)
    IE浏览器跳转url正常,谷歌浏览器跳转报403状态
    书签
    工作记录
    MySQL索引、锁和优化
    Pytorch-张量的创建与使用方法
    网络请求
    数据挖掘的五大流程
    uni开启下拉刷新
    uni-app中的tabBar配置
  • 原文地址:https://www.cnblogs.com/third2333/p/7283377.html
Copyright © 2011-2022 走看看