当前位置:网站首页>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;
}
边栏推荐
- Bugku's file contains
- The picgo shortcut is amazing. This person thinks exactly the same as me
- Comment utiliser le langage MySQL pour les appareils de ligne et de ligne?
- 【每日一题】1175. 质数排列
- Korean AI team plagiarizes shock academia! One tutor with 51 students, or plagiarism recidivist
- Basic use of MySQL
- [nodemon] app crashed - waiting for file changes before starting...解决方法
- Advantages, values and risks of chain games compared with traditional games
- IM即时通讯开发万人群聊消息投递方案
- [SQL statement] Why do you select two Shanghai and query different counts here? I want it to become a Shanghai, and count only displays a sum
猜你喜欢
IM即时通讯开发实现心跳保活遇到的问题
PR basic clip operation / video export operation
SQLServer查询: a.id与b.id相同时,a.id对应的a.p在b.id对应的b.p里找不到的话,就显示出这个a.id和a.p
程序员职业生涯真的很短吗?
圈铁发音,动感与无噪强强出彩,魔浪HIFIair蓝牙耳机测评
Sqlserver query: when a.id is the same as b.id, and the A.P corresponding to a.id cannot be found in the B.P corresponding to b.id, the a.id and A.P will be displayed
What is the digital transformation of manufacturing industry
Principes et applications du système de base de données (006) - - compilation et installation de MySQL 5.7 (environnement Linux)
Comprehensively view the value of enterprise digital transformation
运动捕捉系统原理
随机推荐
sql刷题586. 订单最多的客户
用手机在同花顺上开户靠谱吗?这样有没有什么安全隐患
In the past six months, it has been invested by five "giants", and this intelligent driving "dark horse" is sought after by capital
嗨 FUN 一夏,与 StarRocks 一起玩转 SQL Planner!
软件工程导论——第六章——详细设计
Submission lottery - light application server essay solicitation activity (may) award announcement
I'm a senior test engineer who has been outsourced by Alibaba and now has an annual salary of 40w+. My two-year career changing experience is sad
Do280 management application deployment - pod scheduling control
数据库系统原理与应用教程(006)—— 编译安装 MySQL5.7(Linux 环境)
红队第8篇:盲猜包体对上传漏洞的艰难利用过程
学会了selenium 模拟鼠标操作,你就可以偷懒点点点了
How to use phpipam to manage IP addresses and subnets
瑞典公布决定排除华为5G设备,但是华为已成功找到新出路
[observation] where is the consulting going in the digital age? Thoughts and actions of softcom consulting
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
Why is the pkg/errors tripartite library more recommended for go language error handling?
Sqlserver query: when a.id is the same as b.id, and the A.P corresponding to a.id cannot be found in the B.P corresponding to b.id, the a.id and A.P will be displayed
【Hot100】20. Valid parentheses
Pico, do you want to save or bring consumer VR?
How to repair the laptop that cannot connect to the wireless network