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

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

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

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std; const int MAXN = ;
const double PI = acos(-1.0);
const double EPS = 1e-; struct point
{
double x, y;
point(double x=, double y=):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=; i<=N; i++)
{
scanf("%lf%lf", &Mid[i].x, &Mid[i].y);
if(i&)poly[] = poly[]+Mid[i];
else poly[] = poly[]-Mid[i];
} for(int i=; i<=N; i++)
poly[i+] = Mid[i] * - poly[i]; if(poly[N+].x != poly[].x || poly[N+].y != poly[].y)
printf("NO\n");
else
{
printf("YES\n");
for(int i=; i<=N; i++)
printf("%.3f %.3f\n", poly[i].x, poly[i].y);
} return ;
}
04-18 12:20