当前位置:网站首页>P2592 [zjoi2008] birthday party (DP)
P2592 [zjoi2008] birthday party (DP)
2022-07-01 16:40:00 【Harris-H】
P2592 [ZJOI2008] Birthday party (dp)
dp, The key is how to express the difference between men and women .
So set d p ( i , j , k , l ) dp(i,j,k,l) dp(i,j,k,l) To express with i i i A boy , j j j A girl , The biggest difference between boys and girls is k k k, The biggest difference between girls and boys is l l l.
Then enumerate the quadruple loop dp that will do , Enumerate the boys or girls currently playing .
Time complexity : O ( n m k 2 ) O(nmk^2) O(nmk2)
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<bitset>
#include<deque>
#include<ctime>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define ri register int
#define il inline
#define fi first
#define se second
#define mp make_pair
#define pairint pair<int,int>
#define mem0(x) memset((x),0,sizeof (x))
#define mem1(x) memset((x),0x3f,sizeof (x))
il char gc()
{
static const int BS = 1 << 22;
static unsigned char buf[BS], *st, *ed;
if (st == ed) ed = buf + fread(st = buf, 1, BS, stdin);
return st == ed ? EOF : *st++;
}
#define gc getchar
template<class T>void in(T &x)
{
x = 0;
bool f = 0;
char c = gc();
while (c < '0' || c > '9')
{
if (c == '-') f = 1;
c = gc();
}
while ('0' <= c && c <= '9')
{
x = (x << 3) + (x << 1) + (c ^ 48);
c = gc();
}
if (f) x = -x;
}
#undef gc
#define pb push_back
#define int ll
#define md 12345678
int n,m,d;
int f[155][155][22][22];
il int max(const int &a,const int &b)
{
return a>b?a:b;
}
signed main()
{
#ifdef M207
freopen("in.in", "r", stdin);
#endif
in(n),in(m),in(d);
f[0][0][0][0]=1;
for(ri i=0;i<=n;++i)
for(ri j=0;j<=m;++j)
for(ri k=0;k<=d;++k)
for(ri h=0;h<=d;++h)
if(f[i][j][k][h])
{
// printf("%lld %lld %lld %lld: %lld\n",i,j,k,h,f[i][j][k][h]);
int tmp=f[i][j][k][h];
(f[i+1][j][k+1][max(h-1,0)]+=tmp)%=md;
(f[i][j+1][max(k-1,0)][h+1]+=tmp)%=md;
}
int ans=0;
for(ri i=0;i<=d;++i)
for(ri j=0;j<=d;++j)
(ans+=f[n][m][i][j])%=md;
printf("%lld",ans);
return 0;
}
边栏推荐
- Comment utiliser le langage MySQL pour les appareils de ligne et de ligne?
- Virtual serial port simulator and serial port debugging assistant tutorial "suggestions collection"
- How to restore the system with one click on Lenovo laptop
- Endeavouros mobile hard disk installation
- Basic use of MySQL
- Problems encountered in IM instant messaging development to maintain heartbeat
- 【Hot100】19. Delete the penultimate node of the linked list
- 怎麼用MySQL語言進行行列裝置?
- Use Tencent cloud to build a map bed service
- 普通二本,去过阿里外包,到现在年薪40W+的高级测试工程师,我的两年转行心酸经历...
猜你喜欢

Défaillance lors du démarrage de la machine virtuelle VMware: le poste de travail VMware n'est pas compatible avec hyper - V...

Tutorial on the principle and application of database system (001) -- MySQL installation and configuration: installation of MySQL software (Windows Environment)

数据库系统原理与应用教程(006)—— 编译安装 MySQL5.7(Linux 环境)

Comprehensively view the value of enterprise digital transformation

今天14:00 | 港大、北航、耶鲁、清华、加大等15位ICLR一作讲者精彩继续!

The picgo shortcut is amazing. This person thinks exactly the same as me

怎么用MySQL语言进行行列装置?

Zhou Shaojian, rare

【Hot100】20. Valid parentheses

数据库系统原理与应用教程(003)—— MySQL 安装与配置:手工配置 MySQL(windows 环境)
随机推荐
Preliminary study on golang crawler framework
Why is the pkg/errors tripartite library more recommended for go language error handling?
Stonedb is building blocks for domestic databases, and the integrated real-time HTAP database based on MySQL is officially open source!
圈铁发音,动感与无噪强强出彩,魔浪HIFIair蓝牙耳机测评
Building blocks for domestic databases, stonedb integrated real-time HTAP database is officially open source!
PostgreSQL 存储结构浅析
Is the programmer's career really short?
Zhou Shaojian, rare
How to use MySQL language for row and column devices?
数据库系统原理与应用教程(001)—— MySQL 安装与配置:MySQL 软件的安装(windows 环境)
The picgo shortcut is amazing. This person thinks exactly the same as me
Korean AI team plagiarizes shock academia! One tutor with 51 students, or plagiarism recidivist
免费抽奖 | 《阿巴豆》探索未来系列盲盒数字版权作品全网首发!
How to use F1 to F12 correctly on laptop keyboard
Apple's self-developed baseband chip failed again, which shows Huawei Hisilicon's technological leadership
博睿数据一体化智能可观测平台入选中国信通院2022年“云原生产品名录”
StoneDB 为国产数据库添砖加瓦,基于 MySQL 的一体化实时 HTAP 数据库正式开源!
如何使用phpIPAM来管理IP地址和子网
[nodemon] app crashed - waiting for file changes before starting... resolvent
Problèmes rencontrés dans le développement de la GI pour maintenir le rythme cardiaque en vie