sgu 136 分类: sgu 2015-03-14 22:38 34人阅读 评论(0) 收藏
构造题
根据中点公式列方程,
然后用代入法手算解方程
最后判断方程的根的个数,
如果有根,就构造一组方案
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
const int MAXN = 10005;
const double eps = 1e-8;
int n;
struct node
{
double x,y;
node(double x = 0, double y = 0):x(x), y(y){}
void in(){scanf("%lf%lf",&x,&y);}
void out(){printf("%lf %lf\n",x,y);}
}A[MAXN] = {0}, B[MAXN] = {0};
node operator+(const node &a,const node &b){return node(a.x+b.x,a.y+b.y);}
node operator-(const node &a,const node &b){return node(a.x-b.x,a.y-b.y);}
node operator*(const node &a,const int &b) {return node(a.x*b,a.y*b);}
int main()
{
#ifndef ONLINE_JUDGE
freopen("sgu136.in","r",stdin);
freopen("sgu136.out","w",stdout);
#endif
scanf("%d",&n);
for(int i = 1; i <= n ; i++)B[i].in();
if(n&1)
{
for(int i = 1; i <= n; i++)
if(i&1)A[1] = A[1] + B[i];
else A[1] = A[1] - B[i];
for(int i = 2; i <= n ;i++)
A[i] = B[i-1] * 2 - A[i-1];
puts("YES");
for(int i = 1; i <= n; i++)A[i].out();
}
else
{
for(int i = 1; i <= n; i++)
if(i&1)A[1] = A[1] + B[i];
else A[1] = A[1] - B[i];
if(fabs(A[1].x) < eps && fabs(A[1].y)<eps)
{
A[1].x = A[1].y = 0.1;
for(int i = 2; i <= n ;i++)
A[i] = B[i-1] * 2 - A[i-1];
puts("YES");
for(int i = 1; i <= n; i++)A[i].out();
}
else
puts("NO");
}
#ifndef ONLINE_JUDGE
fclose(stdin);
fclose(stdout);
#endif
}
版权声明:本文为博主原创文章,未经博主允许不得转载。