T1:[JSOI2008]球形空间产生器
消消式子可得2*(a1-b1)x1+2*(a2-b2)*x2+.....+2*(an-bn)xn=a1^2-b1^2+a2^2-b2^2....an^2-bn^2,完
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define re register
#define il inline
#define fp(i,a,b) for(re int i=a;i<=b;i++)
#define fq(i,a,b) for(re int i=a;i>=b;i--)
using namespace std;
const int N=100;
double a[N][N],x[N][N],tot[N],p[N];
int n;
il int gi()
{
re int x=0,t=1;
re char ch=getchar();
while((ch<‘0‘||ch>‘9‘)&&ch!=‘-‘) ch=getchar();
if(ch==‘-‘) t=-1,ch=getchar();
while(ch>=‘0‘&&ch<=‘9‘) x=x*10+ch-48,ch=getchar();
return x*t;
}
int main()
{
scanf("%d",&n);
fp(i,0,n)
fp(j,1,n) scanf("%lf",&x[i][j]),tot[i]+=x[i][j]*x[i][j];
fp(i,1,n)
{
fp(j,1,n) a[i][j]=2*(x[i][j]-x[0][j]);
a[i][n+1]=tot[i]-tot[0];
}
fp(i,1,n)
fp(j,i+1,n)
fq(k,n+1,i)
a[j][k]-=a[i][k]*a[j][i]/a[i][i];
fq(i,n,1)
{
p[i]=a[i][n+1];
fq(j,n,i+1) p[i]-=a[i][j]*p[j];
p[i]/=a[i][i];
}
fp(i,1,n) printf("%.3lf ",p[i]);
return 0;
}