rt。剩下的都是 Wrong Answer.wrong answer On line 1 column 1, read 0, expected *.??
#include <bits/stdc++.h>
using namespace std;
const int D{10};
int Di,n;
double sqr(double x) {return x*x;}
struct Point {
double x[D];
friend double dis(const Point& a,const Point& b) {
double ans{0};
for (int i{0};i<Di;++i)
ans+=sqr(a.x[i]-b.x[i]);
return sqrt(ans);
}
} a[D+5],O,Op,Z;
double ds[D+5],mD;
double calc() {
double x{0},c{0};
for (int i{1};i<=n;++i)
x+=ds[i]=dis(a[i],O);
x/=n;
for (int i{1};i<=n;++i)
c+=sqr(ds[i]-x);
c/=n;
return c*sqr(x);
}
random_device e;
uniform_real_distribution<double> u(-2000,2000);
double ans{1145141919810};
void SA() {
for (double T{100};T>=1e-7;T*=0.99) {
Point P;
for (int i{0};i<Di;++i)
P.x[i]=O.x[i]+T*u(e);
swap(P,O);
double res=calc();
if (res<ans) ans=res,Op=O;
else if (exp((ans-res)/T)*RAND_MAX<rand()) swap(P,O);
}
}
int main() {
cin>>Di;n=Di+1;
for (int i{1};i<=n;++i)
for (int j{0};j<Di;++j)
cin>>a[i].x[j];
for (int i{1};i<=n;++i)
for (int j{i+1};j<=n;++j)
mD=max(mD,dis(a[i],a[j]));
for (int j{0};j<Di;++j) {
double sum{0};
for (int i{1};i<=n;++i)
sum+=a[i].x[j];
O.x[j]=sum/n;
}
O=Op=Z;
clock_t st{clock()};
while (clock()-st<=0.9*CLOCKS_PER_SEC) {
SA();
}
for (int i{0};i<Di;++i)
cout<<fixed<<setprecision(3)<<Op.x[i]<<" ";
cout<<endl;
}