求助
  • 板块灌水区
  • 楼主RAY091016
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/12/10 18:53
  • 上次更新2024/12/10 18:58:02
查看原帖
求助
772875
RAY091016楼主2024/12/10 18:53
#include<bits/stdc++.h>
using namespace std;
const int maxn=30;
struct Node{
    int x,y;
}dot[maxn];
int n;
double dp[1<<maxn];
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>dot[i].x>>dot[i].y;
    }
    dp[0]=0;
    for(int i=1;i<(1<<n);i++){
        dp[i]=1e9;
    }
    for(int s=1;s<(1<<n);s++){
        for(int i=0;i<n;i++){
            if(s&(1<<i)) break;
	        for(int j=i+1;j<n;j++){
	            if(s&(1<<j)){
	                dp[s]=min(dp[s],sqrt((dot[i].x-dot[j].x)*(dot[i].x-dot[j].x)+(dot[i].y-dot[j].y)*(dot[i].y-dot[j].y))+dp[s^(1<<i)^(1<<j)]);
	            }
	        }
	    }
    }
    printf("%0.2lf",dp[(1<<n)-1]);
    return 0;
}

为何编译错误?

2024/12/10 18:53
加载中...