zoukankan      html  css  js  c++  java
  • Erasing Edges

    题目大意:已知一个多边形上的每条边的中点,还原出来一个多边形。

    分析:因为偶数是不固定的,所以可以为任意起点,奇数只有一个,可以所有中点加减算出来第一个点,然后就是简单的向量计算点的位置了......

    ==================================================================================================================

    #include<stdio.h>
    #include<string.h>
    #include<math.h>
    #include<algorithm>
    using namespace std;
    
    const int MAXN = 10007;
    const double PI = acos(-1.0);
    const double EPS = 1e-7;
    
    struct point
    {
        double x, y;
        point(double x=0, double y=0):x(x),y(y){}
        point operator - (const point &tmp)const{
            return point(x-tmp.x, y-tmp.y);
        }
        point operator + (const point &tmp)const{
            return point(x+tmp.x, y+tmp.y);
        }
        point operator * (const int &t)const{
            return point(x*t, y*t);
        }
    }Mid[MAXN], poly[MAXN];
    
    int main()
    {
        int N;
    
        scanf("%d", &N);
    
        for(int i=1; i<=N; i++)
        {
            scanf("%lf%lf", &Mid[i].x, &Mid[i].y);
            if(i&1)poly[1] = poly[1]+Mid[i];
            else poly[1] = poly[1]-Mid[i];
        }
    
        for(int i=1; i<=N; i++)
            poly[i+1] = Mid[i] * 2 - poly[i];
    
        if(poly[N+1].x != poly[1].x || poly[N+1].y != poly[1].y)
            printf("NO
    ");
        else
        {
            printf("YES
    ");
            for(int i=1; i<=N; i++)
                printf("%.3f %.3f
    ", poly[i].x, poly[i].y);
        }
    
        return 0;
    }
  • 相关阅读:
    JQuery UI
    JQuery 插件
    JQuery Ajax
    varchar和Nvarchar区别
    git冲突解决
    jquery ajax 提交信息后等待返回的提示信息
    Oracle错误 ORA-12560如何解决
    putty ssh连接老断
    myeclipse操作记录
    HTML与HTML5笔记
  • 原文地址:https://www.cnblogs.com/liuxin13/p/4856829.html
Copyright © 2011-2022 走看看