HDU 2861 四维dp打表
O means that the stool in a certain position is used, while E means that the stool in a certain position is empty (here what we care is not who sits on the stool, but whether the stool is empty).As the example we show above, we can say the situation how the 15 stools is used determines 7 intervals (as following):
OO E OOOO EEE OOO E O
Now we postulate that there are N stools and M customers, which make up K intervals. How many arrangements do you think will satisfy the condition?
Each case contains three integers N (0<N<=200), M (M<=N), K (K<=20).
4 2 4
dp[i+1][j][k][0]=dp[i][j][k][0]+dp[i][j][k-1][1];
dp[i+1][j][k][1]=dp[i][j-1][k-1][0]+dp[i][j-1][k][1];
打表然后查询输出
#include<iostream>
#include<cstdio>
using namespace std;
long long dp[][][][];
int main()
{
int n=,m=,ak=,i,j,k;
dp[][][][]=;
dp[][][][]=;
for(i=;i<=n;i++)
{
for(j=;j<=m;j++)
{
for(k=;k<=ak;k++)
{
dp[i+][j][k][]=dp[i][j][k][]+dp[i][j][k-][];
if(j!=)
dp[i+][j][k][]=dp[i][j-][k-][]+dp[i][j-][k][];
}
}
}
while(scanf("%d%d%d",&n,&m,&ak)!=EOF)
{
cout<<dp[n][m][ak][]+dp[n][m][ak][]<<endl;
}
return ;
}
HDU 2861 四维dp打表的更多相关文章
- hdu 5179(数位DP||打表)
beautiful number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- CodeForces 682D Alyona and Strings (四维DP)
Alyona and Strings 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/D Description After re ...
- hdu 4123 树形DP+RMQ
http://acm.hdu.edu.cn/showproblem.php? pid=4123 Problem Description Bob wants to hold a race to enco ...
- hdu 4507 数位dp(求和,求平方和)
http://acm.hdu.edu.cn/showproblem.php?pid=4507 Problem Description 单身! 依旧单身! 吉哥依旧单身! DS级码农吉哥依旧单身! 所以 ...
- hdu 3709 数字dp(小思)
http://acm.hdu.edu.cn/showproblem.php?pid=3709 Problem Description A balanced number is a non-negati ...
- hdu 4352 数位dp + 状态压缩
XHXJ's LIS Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- hdu 4283 区间dp
You Are the One Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- 【bzoj5161】最长上升子序列 状压dp+打表
题目描述 现在有一个长度为n的随机排列,求它的最长上升子序列长度的期望. 为了避免精度误差,你只需要输出答案模998244353的余数. 输入 输入只包含一个正整数n.N<=28 输出 输出只包 ...
- HDU 2829 区间DP & 前缀和优化 & 四边形不等式优化
HDU 2829 区间DP & 前缀和优化 & 四边形不等式优化 n个节点n-1条线性边,炸掉M条边也就是分为m+1个区间 问你各个区间的总策略值最少的炸法 就题目本身而言,中规中矩的 ...
随机推荐
- MySQL学习笔记——存储过程
- NumberFormat类
NumberFormat表示数字的格式化类,即可以按照本地的风格习惯进行数字的显示. NumberFormat是一个抽象类,和MessageFormat类一样,都是Format类的子类,本类在使用时可 ...
- nginx配置文件详解( 看着好长,其实不长,看了就知道了,精心整理,有些配置也是没用到呢 )
user www www; #定义Nginx运行的用户和用户组 worker_processes ; #nginx进程数,建议设置为CPU核数2倍. error_log var/log/ ...
- sqlserver权限体系(上)
简介 权限两个字,一个权力,一个限制.在软件领域通俗的解释就是哪些人可以对哪些资源做哪些操作. 在SQL Server中,”哪些人”,“哪些资源”,”哪些操作”则分别对应SQL Server中的三个对 ...
- 改变Vim在iTerm2中的光标
vim ~/.vimrc 添加 " Change cursor shape between insert and normal mode in iTerm2.appif $TERM_PROG ...
- singleton和prototype
public class testScope { @Test public void test() { //默任singleton ApplicationContext ctx= new ClassP ...
- Centos安装Kafka集群
kafka是LinkedIn开发并开源的一个分布式MQ系统,现在是Apache的一个孵化项目.在它的主页描述kafka为一个高吞吐量的分布式(能 将消息分散到不同的节点上)MQ.在这片博文中,作者简单 ...
- 存储过程中的when others then 和 raise
EXCEPTION when others then rollback; dbms_output.put_line('code:' || sqlcode); dbms_output.put_line( ...
- hdu4965 Fast Matrix Calculation (矩阵快速幂 结合律
http://acm.hdu.edu.cn/showproblem.php?pid=4965 2014 Multi-University Training Contest 9 1006 Fast Ma ...
- SQL笔记 - 解决CTE定位点类型和递归部分的类型不匹配
在CTE递归测试,也就是部门名称拼接的时候,遇到了小问题: 登时就迷糊了:不都是取的是Unit表中的同一个列,相加之后类型就变了么? 难道是因为,系统知道这是在进行递归运算,但又不确定递归的层次,以及 ...