#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int f[1<<10], a[10][10];int main(){ int n; while(scanf("%d", &n), n) { for(int i = 0; i < n; ++i) for(int j = 0; j < n; ++j) scanf("%d", &a[i][j]); memset(f, 0, sizeof(f)); for(int i = 0; i < (1<<n); ++i) { for(int j = 0; j < n; ++j) { if((i & 1<<j) == 0) { for(int k = 0; k < n; ++k) { if((j != k) && (i & 1<<k) != 0) { f[i | 1<<j] = max(f[i | 1<<j], f[i] + a[k][j]); } } } } } int ans = 0; for(int i = 0; i < (1<<n); ++i) { ans = max(ans, f[i]); } printf("%dn", ans); } return 0;}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)