#include <iostream>
#include <cstring>
using namespace std;

const int N = 110;

struct node{
    int v;
    bool st;
}g[N][N];

int n;
int res;

void dfs(int u, int s)
{
    if(u == n + 1){
        res = max(res, s);
        return;
    }
    for(int i = 1; i <= n; i++){
        if(g[u][i].st == 0){
            g[u][i].st = 1;
            dfs(u + 1, s + u * g[u][i].v);
            g[u][i].st = 0;
        }
    }
}

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin >> g[i][j].v;
        }
    }
    dfs(1, 0);
    cout << res << endl;
    return 0;
}
``
# 取数游戏## 题目描述给出一个 $ntimes n$ 的矩阵进行取数游戏。取数共 $n$ 轮第 $i$ 轮需要从每行分别取一个没取过的数字设取出的数字总和是 $s$则第 $i$ 轮的实际得分是 $itimes s$。求 $n$ 轮取数的最大总得分。## 输入格式从标准输入读入数据。第一行输入一个正整数 $n$$nle100$。接下来 $n$ 行每行输入 $n$ 个正整数 $a_ij$$a_ij

原文地址: https://www.cveoy.top/t/topic/dHzo 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录