[hdoj6415 Rikka with Nash Equilibrium][dp]
http://acm.hdu.edu.cn/showproblem.php?pid=6415
Rikka with Nash Equilibrium
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 2021 Accepted Submission(s): 857
Rikka and Yuta are playing a simple matrix game. At the beginning of the game, Rikka shows an n×m integer matrix A. And then Yuta needs to choose an integer in [1,n], Rikka needs to choose an integer in [1,m]. Let i be Yuta's number and j be Rikka's number, the final score of the game is Ai,j.
In the remaining part of this statement, we use (i,j) to denote the strategy of Yuta and Rikka.
For example, when n=m=3 and matrix A is
If the strategy is (1,2), the score will be 2; if the strategy is (2,2), the score will be 4.
A pure strategy Nash equilibrium of this game is a strategy (x,y) which satisfies neither Rikka nor Yuta can make the score higher by changing his(her) strategy unilaterally. Formally, (x,y) is a Nash equilibrium if and only if:
In the previous example, there are two pure strategy Nash equilibriums: (3,1) and (2,2).
To make the game more interesting, Rikka wants to construct a matrix A for this game which satisfies the following conditions:
1. Each integer in [1,nm] occurs exactly once in A.
2. The game has at most one pure strategy Nash equilibriums.
Now, Rikka wants you to count the number of matrixes with size n×m which satisfy the conditions.
The first line of each testcase contains three numbers n,m and K(1≤n,m≤80,1≤K≤109).
The input guarantees that there are at most 3 testcases with max(n,m)>50.
3 3 100
5 5 2333
1170
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[][][];
int pre[][];
int main()
{
int t;
scanf("%d",&t);
while(t--){
int n,m,k;
scanf("%d%d%d",&n,&m,&k);
memset(dp,,sizeof(dp));
dp[][][]=n*m;
for(int q=;q<=n*m;q++){
for(int i=min(n,q);i>=;i--){
for(int j=min(m,q-i+);j>=;j--){
if(i*j<q-)break;
dp[i][j][]=(dp[i][j][]+dp[i][j][]+dp[i][j][])%k*((i*j)-(q-))%k;
dp[i][j][]=(dp[i-][j][]+dp[i-][j][]+dp[i-][j][])%k*(n*j-(i-)*j)%k;
dp[i][j][]=(dp[i][j-][]+dp[i][j-][]+dp[i][j-][])%k*(m*i-i*(j-))%k;
}
}
}
printf("%lld\n",(dp[n][m][]+dp[n][m][]+dp[n][m][])%k);
}
return ;
}
注意:这道题如果不通过判断某些条件及时跳出循环就会T掉
[hdoj6415 Rikka with Nash Equilibrium][dp]的更多相关文章
- 杭电多校第九场 HDU6415 Rikka with Nash Equilibrium dp
Rikka with Nash Equilibrium Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K ...
- hdu6415 Rikka with Nash Equilibrium (DP)
题目链接 Problem Description Nash Equilibrium is an important concept in game theory. Rikka and Yuta are ...
- hdu-6415 Rikka with Nash Equilibrium dp计数题
http://acm.hdu.edu.cn/showproblem.php?pid=6415 题意:将1~n*m填入一个n*m矩阵 问只有一个顶点的构造方案. 顶点的定义是:某数同时是本行本列的最大值 ...
- HDU - 6415 多校9 Rikka with Nash Equilibrium(纳什均衡+记忆化搜索/dp)
Rikka with Nash Equilibrium Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K ...
- 【杂题总汇】HDU2018多校赛第九场 Rikka with Nash Equilibrium
[HDU2018多校赛第九场]Rikka with Nash Equilibrium 又是靠这样一道题擦边恰好和第两百名分数一样~愉快
- HDU6415 Rikka with Nash Equilibrium
HDU6415 Rikka with Nash Equilibrium 找规律 + 大数 由于规律会被取模破坏,所以用了java 找出规律的思路是: 对于一个n*m的矩阵构造,我先考虑n*1的构造,很 ...
- HDU 6415 Rikka with Nash Equilibrium (计数DP)
题意:给两个整数n,m,让你使用 1 ~ n*m的所有数,构造一个矩阵n*m的矩阵,此矩阵满足:只有一个元素在它的此行和此列中都是最大的,求有多种方式. 析:根据题意,可以知道那个元素一定是 n * ...
- 三十分钟理解博弈论“纳什均衡” -- Nash Equilibrium
欢迎转载,转载请注明:本文出自Bin的专栏blog.csdn.net/xbinworld. 技术交流QQ群:433250724,欢迎对算法.技术感兴趣的同学加入. 纳什均衡(或者纳什平衡),Nash ...
- HDU 6092 17多校5 Rikka with Subset(dp+思维)
Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he ...
随机推荐
- [CF37D]Lesson Timetable_动态规划
Lesson Timetable 题目链接:https://www.codeforces.com/contest/37/problem/D 数据范围:略. 题解: 根本就没想到可以动态规划. 首先从前 ...
- json 和对象互相转换
json 和对象互相转换 导入 Jar 包: import com.fasterxml.jackson.databind.ObjectMapper; Maven 地址: <!-- https:/ ...
- SQLServer 查询view中是否包含某个关键字
在数据库view的创建中,会遇到一些跨数据库的view脚本,但是在将view更新到production的时候可能忘记更改database name,导致出现一些问题. 以下脚本可以检查出包含某个关键字 ...
- JWT 身份认证优缺点分析以及常见问题解决方案
本文转载自:JWT 身份认证优缺点分析以及常见问题解决方案 Token 认证的优势 相比于 Session 认证的方式来说,使用 token 进行身份认证主要有下面三个优势: 1.无状态 token ...
- 1269: 划分数(Java)
WUSTOJ 1269: 划分数 参考博客 果7的博客 题目 将 1 个数 n 分成 m 份,求划分的种数.更多内容点击标题. 分析 唯一需要注意的地方是不考虑顺序.其他的直接看代码即可. 代 ...
- Yii2 基于header 实现接口版本控制
Yii2 官方给出的方案是基于url的版本控制,但是我们的versoin放在header里面,需要通过header来进行版本控制,实现如下: 首先在基类中实现actions,actions是针对con ...
- centos7搭建EFK日志分析系统
前言 EFK可能都不熟悉,实际上EFK是大名鼎鼎的日志系统ELK的一个变种 在没有分布式日志的时候,每次出问题了需要查询日志的时候,需要登录到Linux服务器,使用命令cat -n xxxx|grep ...
- LOJ2557 CTSC2018组合数问题(提交答案)
直接利用simulator退火应该可以得到大量分数. op=1:1,4,5,6,10 即构造序列{ai},最小化Σti,ai+rai,aj. 1:暴搜/退火. 4:观察到图大致成一条链(注意其中有两个 ...
- NeurIPS 2018 中的贝叶斯研究
NeurIPS 2018 中的贝叶斯研究 WBLUE 2018年12月21日 雷锋网 AI 科技评论按:神经信息处理系统大会(NeurIPS)是人工智能领域最知名的学术会议之一,NeurIPS 2 ...
- ORA-07445: exception encountered: core dump [opiaba()+639] [SIGSEGV] [ADDR:0x0] [PC:0x1858C3F] [SI_KERNEL(general_protection)] []
开发反馈应用无法连接数据库,发现数据库实例崩溃,且数据库为11.2.0.4 单实例. 数据库告警日志发现,数据库崩溃之前出现ORA- ORA-: exception encountered: core ...