求各位大佬指正
查看原帖
求各位大佬指正
1631549
cordial楼主2025/1/2 09:42

求各位大佬指正,这个暴力解为啥只有30分,我看别人暴力解也能90或者直接通过 #include #include<math.h>//一开始没加这个头文件,vs可以编译,但洛谷编译通过不了

#include <iostream>
#include<math.h>//一开始没加这个头文件,vs可以编译,但洛谷编译通过不了
using namespace std;
struct point {
	double x, y;
};
int main() {
	int n,i,j;
	double num=123456789.0;
	point p[10010];
	cin >> n;
	for (i = 0;i < n;i++) {
		cin >> p[i].x >> p[i].y;
	}
	for (i = 0;i < n;i++) {
		for (j = i+1;j < n;j++) {
			num = min(num, sqrt(1.0 * (pow(p[i].x - p[j].x, 2) + pow(p[i].y - p[j].y, 2))));
		}
	}
	cout << num << endl;
	return 0;
}
2025/1/2 09:42
加载中...