为防止广告,目前nocow只有登录用户能够创建新页面。如要创建页面请先登录/注册(新用户需要等待1个小时才能正常使用该功能)。
Sgu/136
来自NOCOW
< Sgu
这道题可以将x和y列方程,然后分开解出。
从第一个样例可以列出方程
x1+x2=0
x2+x3=4
x3+x4=4
x4+x1=0
y1+y2=0
y2+y3=0
y3+y4=4
y4+y1=4
容易发现,当n为偶数时,要么无解,要么有无穷个解,当n为奇数时,有且仅有一个解。
//by a710128 #include<iostream> #include<cstdio> using namespace std; int n; double x[10005],y[10005],tx[2],ty[2]; void out(double xx,double yy) { for(int i=1;i<=n;i++) { printf("%0.3lf %0.3lf\n",xx,yy); xx=x[i]*2-xx; yy=y[i]*2-yy; } return ; } int main() { cin>>n; for(int i=1;i<=n;i++) {cin>>x[i]>>y[i];tx[i&1]+=2*x[i];ty[i&1]+=2*y[i];} if(n&1) {cout<<"YES"<<endl;out((tx[1]-tx[0])/2,(ty[1]-ty[0])/2);} else if(tx[0]==tx[1]&&ty[0]==ty[1]) {cout<<"YES"<<endl;out(-1,1);} else cout<<"NO"<<endl; return 0; }
#include <stdio.h> #include <math.h> using namespace std; #define eps 1e-6 double x[10000], y[10000], tx, ty; int n; int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%lf %lf", &x[i], &y[i]); tx = x[i] - tx; ty = y[i] - ty; } if (!(n & 1)) if (fabs(tx) < eps && fabs(ty) < eps) { tx = -1; ty = 1; } else { puts("NO"); return 0; } puts("YES"); for (int i = 0; i < n; ++i) { printf("%.3lf %.3lf\n", tx, ty); tx = x[i] * 2 - tx; ty = y[i] * 2 - ty; } return 0; } // From FingerSed