。
代码如下:
#include#include #include const double INF = (1<<25);#define MAXN 103#define MAXM 10010struct Pos{ int x, y;}pos[MAXN];int vis[MAXN];double G[MAXN][MAXN], d[MAXN], ans;double calc(struct Pos a, struct Pos b){ int k = (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y); if(k<100 || k>1000000) return INF; else return sqrt(k*1.0);}int prim(int n){ int i, x, y, flag; double m; for(i=0; i d[y]) {m = d[x=y]; flag = 1;} if(!flag) break; vis[x] = 1; ans += m; for(y=0; y G[x][y]) d[y] = G[x][y]; } return flag;}int main(){ int n, i, j, T; scanf("%d", &T); while(T--){ scanf("%d", &n); ans = 0.0; for(i=0; i