Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 1251    Accepted Submission(s): 506


Problem Description
Nash Equilibrium is an important concept in game theory.

Rikka and Yuta are playing a simple matrix game. At the beginning of the game, Rikka shows an A is 
⎤⎦⎥

If the strategy is )
 is a Nash equilibrium if and only if:
]
m which satisfy the conditions.
 

 

Input
The first line contains a single integer 50.
 

 

Output
For each testcase, output a single line with a single number: the answer modulo K.
 

 

Sample Input
2 3 3 100 5 5 2333
 

 

Sample Output
64 1170
 

 

Source
 

 

Recommend
chendu   |   We have carefully selected several similar problems for you:  6425 6424 6423 6422 6421 
 
题意:

在一个矩阵中,如果某一个数字是该行该列的最大值,则这个数满足纳什均衡。

要求构造一个n*m的矩阵,里面填的数字各不相同且范围是【1,m*n】,且矩阵内最多有一个数满足纳什平衡,问有多少种构造方案。

分析:

从大到小往矩阵里填数,则填的数会多占领一行或者多占领一列或者不占领(上方左方都有比他更大的数)

多占领一行,则这一行可任意填的位置是是这一行还没填的列

多占领一列,同理

特殊考虑:有更大的数还没填进去的情况

参考博客:

https://blog.csdn.net/monochrome00/article/details/81875980

AC代码:

#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define ls (r<<1)
#define rs (r<<1|1)
#define debug(a) cout << #a << " " << a << endl
using namespace std;
typedef long long ll;
const ll maxn = 1e6+10;
//const ll mod = 998244353;
const double pi = acos(-1.0);
const double eps = 1e-8;
ll n, m, mod, dp[85][85][85*85];
int main() {
    ios::sync_with_stdio(0);
    ll t;
    cin >> t;
    while( t -- ) {
        cin >> n >> m >> mod;
        dp[n][m][n*m] = 1;  //占领了n-n+1行m-m+1列,放入了n*m-n*m+1个数字
        for( ll k = n*m-1; k >= 1; k -- ) {
            for( ll i = n; i >= 1; i -- ) { //从最后一行一列开始放最大的数字
                for( ll j = m; j >= 1; j -- ) {
                    if( i*j < k ) {
                        break;
                    }
                    dp[i][j][k] = j*(n-i)%mod*dp[i+1][j][k+1]%mod; //多占领了一行,这一行还没放的位置可以随意放
                    dp[i][j][k] = (dp[i][j][k]+i*(m-j)%mod*dp[i][j+1][k+1]%mod)%mod; //多占领了一列,同上
                    dp[i][j][k] = (dp[i][j][k]+(i*j-k)%mod*dp[i][j][k+1]%mod)%mod; //还有更大的数没有放进去的情况
                }
            }
        }
        cout << n*m%mod*dp[1][1][1]%mod << endl;
    }
    return 0;
}

  

相关文章: