当前位置:网站首页>[ahoi2009]chess Chinese chess - combination number optimization shape pressure DP
[ahoi2009]chess Chinese chess - combination number optimization shape pressure DP
2022-07-06 10:58:00 【Wawa source】
Topic link
Excerpt from :
Dream_Maker_yangkai
link
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long
const int N = 110,mod = 9999973;
int f[N][N][N];
int C[N][N];
int n,m;
signed main()
{
cin>>n>>m;
for(int i=0;i<N;i++){
for(int j=0;j<=i;j++){
if(!j)C[i][j]=1;
else C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
}
}
if(n<m)swap(n,m);
f[0][0][0]=1;
//f[i][j][k] To i That's ok , Yes j Listed 1 Number ,k Listed 2 The number of schemes .
for(int i=1;i<=n;i++)
{
for(int j=0;j<=m;j++)
{
for(int k=0;k<=m-j;k++)
{
int &v=f[i][j][k];
// Choose nothing
v=f[i-1][j][k];
// The first i OK, let's go 1 individual Put the quantity as 0 On the list of
if(j)v=(v+f[i-1][j-1][k]*C[m-j-k+1][1]%mod)%mod;
// The first i OK, let's go 1 individual Put the quantity as 1 On the list of
if(k>=1&&j<=m-1)v=(v+f[i-1][j+1][k-1]*C[j+1][1]%mod)%mod;
// The first i OK, let's go 2 individual Put them into two quantities respectively 0 On the list of
if(j>=2)v=(v+f[i-1][j-2][k]*C[m-j-k+2][2]%mod)%mod;
// The first i OK, let's go 2 individual Put them in a quantity of 0 and 1 On the list of
if(j&&k)v=(v+f[i-1][j][k-1]*j%mod*(m-j-k+1)%mod)%mod;
// The first i OK, let's go 2 individual Put them into two quantities respectively 1 On the list of
if(k>=2&&j<=m-2)v=(v+f[i-1][j+2][k-2]*C[j+2][2]%mod)%mod;
}
}
}
int res=0;
for(int i=0;i<=m;i++)
for(int j=0;j<=m-i;j++)
res=(res+f[n][i][j])%mod;
cout<<res<<endl;
}
边栏推荐
- Postman environment variable settings
- Installation and use of MySQL under MySQL 19 Linux
- Idea import / export settings file
- MySQL30-事务基础知识
- API learning of OpenGL (2004) gl_ TEXTURE_ MIN_ FILTER GL_ TEXTURE_ MAG_ FILTER
- Ansible实战系列二 _ Playbook入门
- [recommended by bloggers] C MVC list realizes the function of adding, deleting, modifying, checking, importing and exporting curves (with source code)
- MySQL 29 other database tuning strategies
- CSDN question and answer tag skill tree (II) -- effect optimization
- Moteur de stockage mysql23
猜你喜欢
随机推荐
Windchill configure remote Oracle database connection
How to change php INI file supports PDO abstraction layer
Mysql33 multi version concurrency control
A trip to Macao - > see the world from a non line city to Macao
Invalid global search in idea/pychar, etc. (win10)
解决:log4j:WARN Please initialize the log4j system properly.
CSDN问答模块标题推荐任务(二) —— 效果优化
Ansible实战系列二 _ Playbook入门
NPM an error NPM err code enoent NPM err syscall open
February 13, 2022 - Maximum subarray and
Installation and use of MySQL under MySQL 19 Linux
该不会还有人不懂用C语言写扫雷游戏吧
Mysql30 transaction Basics
[recommended by bloggers] asp Net WebService background data API JSON (with source code)
Pytoch LSTM implementation process (visual version)
Win10: how to modify the priority of dual network cards?
Global and Chinese market of transfer switches 2022-2028: Research Report on technology, participants, trends, market size and share
Swagger、Yapi接口管理服务_SE
The virtual machine Ping is connected to the host, and the host Ping is not connected to the virtual machine
February 13, 2022-2-climbing stairs