#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;
class Node{
public:
int x;
int y;
int z;
};
Node a[50001];
bool cmp(Node s1, Node s2){
if(s1.z > s2.z) return false;
return true;
}
int main(){
int n;
cin >> n;
double ans = 0;
for(int i = 1; i <= n; i++) cin >> a[i].x >> a[i].y >> a[i].z;
sort(a, a+n+1, cmp);
for(int i = 1; i < n; i++){
ans += sqrt(pow(a[i].x-a[i+1].x, 2) + pow(a[i].y-a[i+1].y, 2) + pow(a[i].z-a[i+1].z, 2));
}
printf("%.3f", ans);
return 0;
}
有哪位大佬能报给我看看这段代码,案例过了,交上去只有三十分,将结构体中的int改为double也不行,本蒟蒻实在是搞不懂。