垃圾代码99分求助
查看原帖
垃圾代码99分求助
957205
Frommyvalleyuphard楼主2023/7/20 17:22
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
struct sbsbsb{
	long long sbsbsbsb,sbsbsbsbsb;
};
bool sbsb(sbsbsb sb222,sbsbsb sb333){
	return sb222.sbsbsbsb<sb333.sbsbsbsb;
}
using namespace std;
int main(){
    int a;
    cin>>a;
    double sb=pow(10,18);
    int b[a][2]={};
    sbsbsb c[a];
    for(int e=0;e<a;e++){
        cin>>b[e][0]>>b[e][1];
        c[e].sbsbsbsb=b[e][0]+b[e][1];
        c[e].sbsbsbsbsb=e;
    }
    sort(c,c+a,sbsb);
    for(int f=0;f<a;f++){
			for(int g=f+1;g<a;g++){
				if(pow(double(c[f].sbsbsbsb)/2-double(c[g].sbsbsbsb)/2,2)*2>=sb){
					break;
				}
				sb=min(sb,abs(pow(b[c[f].sbsbsbsbsb][0]-b[c[g].sbsbsbsbsb][0],2)+pow(b[c[f].sbsbsbsbsb][1]-b[c[g].sbsbsbsbsb][1],2)));
			}
		}
		cout<<fixed<<setprecision(4)<<pow(sb,0.5);
}

复杂度:O(n~n*(n+1)/2)

2023/7/20 17:22
加载中...