#include <bits/stdc++.h>
using namespace std;
double dp[21][1100000];
int n;
struct City
{
double x;
double y;
};
City city[21];
double dis[21][21];
double getDis(City a, City b)
{
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
int cnt;
int main()
{
int t;
cin >> t;
while (t--)
{
cin >> n;
cnt = 1;
for (int i = 2; i < n; i++)
{
cnt <<= 1;
}
for (int i = 0; i < n; i++)
{
cin >> city[i].x >> city[i].y;
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
dis[i][j] = getDis(city[i], city[j]);
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < cnt; j++)
TSP问题动态规划解决
最新推荐文章于 2024-07-21 10:19:12 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)