当前位置:网站首页>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;
}
边栏推荐
- 部门来了个拿25k出来的00后测试卷王,老油条表示真干不过,已被...
- Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?
- 苹果自研基带芯片再次失败,说明了华为海思的技术领先性
- Problèmes rencontrés dans le développement de la GI pour maintenir le rythme cardiaque en vie
- Motion capture system for apple picking robot
- 复杂度相关OJ题(LeetCode、C语言、复杂度、消失的数字、旋转数组)
- 数据库系统原理与应用教程(005)—— yum 离线安装 MySQL5.7(Linux 环境)
- 巴比特 | 元宇宙每日必读:奈雪币、元宇宙乐园、虚拟股票游戏...奈雪的茶这波“操作拉满”的营销活动你看懂了吗?...
- Zabbix2.2监控之系统及应用日志监控报警
- EndeavourOS移动硬盘安装
猜你喜欢

How to restore the system of Sony laptop

【Hot100】20. Valid parentheses

China's intelligent transportation construction from the perspective of "one hour life circle" in Dawan District

Germany if was crowned with many awards. How strong is this pair of headphones? In depth evaluation of yinpo GTW 270 hybrid

Problems encountered in IM instant messaging development to maintain heartbeat

VMware 虚拟机启动时出现故障:VMware Workstation 与 Hyper-v 不兼容...

实现数字永生还有多久?元宇宙全息真人分身#8i

免费抽奖 | 《阿巴豆》探索未来系列盲盒数字版权作品全网首发!

你还在用收费的文档管理工具?我这有更牛逼的选择!完全免费

【Hot100】20. 有效的括号
随机推荐
软件工程导论——第六章——详细设计
高端程序员上班摸鱼指南
How to solve the problem that the battery icon of notebook computer does not display
Problems encountered in IM instant messaging development to maintain heartbeat
芯片供应转向过剩,中国芯片日产增加至10亿,国外芯片将更难受
sql刷题627. 变更性别
红队第8篇:盲猜包体对上传漏洞的艰难利用过程
What are the differences between PHP and DW
数据库系统原理与应用教程(003)—— MySQL 安装与配置:手工配置 MySQL(windows 环境)
Rhcsa Road
圈铁发音,动感与无噪强强出彩,魔浪HIFIair蓝牙耳机测评
德国iF多项大奖加冕,这副耳机有多强?音珀GTW 270 Hybrid深度评测
Use Tencent cloud to build a map bed service
部门来了个拿25k出来的00后测试卷王,老油条表示真干不过,已被...
How to maintain the laptop battery
MLPerf Training v2.0 榜单发布,在同等GPU配置下百度飞桨性能世界第一
The Department came to a Post-00 test paper king who took out 25K. The veteran said it was really dry, but it had been
Origin2018安装与使用(整理中)
运动捕捉系统原理
IM即时通讯开发实现心跳保活遇到的问题