Patti and Terri run a bar in which there are 15 stools. One day, Darrell entered the bar and found that the situation how customers chose the stools were as follows:
OOEOOOOEEEOOOEO
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?
 
Input
There are multi test cases and for each test case:
Each case contains three integers N (0<N<=200), M (M<=N), K (K<=20).
 
Output
For each test case print the number of arrangements as described above. (All answers is fit in 64-bit.)
 
Sample Input
3 1 3
4 2 4
 
Sample Output
1 2
 
 
 
n个位置坐了m个人分成了k块,求所有可能的种数;
关键是dp表达式
i 0-200
j 0-200
k 1-20

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打表的更多相关文章

  1. hdu 5179(数位DP||打表)

    beautiful number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  2. CodeForces 682D Alyona and Strings (四维DP)

    Alyona and Strings 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/D Description After re ...

  3. hdu 4123 树形DP+RMQ

    http://acm.hdu.edu.cn/showproblem.php? pid=4123 Problem Description Bob wants to hold a race to enco ...

  4. hdu 4507 数位dp(求和,求平方和)

    http://acm.hdu.edu.cn/showproblem.php?pid=4507 Problem Description 单身! 依旧单身! 吉哥依旧单身! DS级码农吉哥依旧单身! 所以 ...

  5. hdu 3709 数字dp(小思)

    http://acm.hdu.edu.cn/showproblem.php?pid=3709 Problem Description A balanced number is a non-negati ...

  6. hdu 4352 数位dp + 状态压缩

    XHXJ's LIS Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  7. hdu 4283 区间dp

    You Are the One Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  8. 【bzoj5161】最长上升子序列 状压dp+打表

    题目描述 现在有一个长度为n的随机排列,求它的最长上升子序列长度的期望. 为了避免精度误差,你只需要输出答案模998244353的余数. 输入 输入只包含一个正整数n.N<=28 输出 输出只包 ...

  9. HDU 2829 区间DP & 前缀和优化 & 四边形不等式优化

    HDU 2829 区间DP & 前缀和优化 & 四边形不等式优化 n个节点n-1条线性边,炸掉M条边也就是分为m+1个区间 问你各个区间的总策略值最少的炸法 就题目本身而言,中规中矩的 ...

随机推荐

  1. 开源License

    http://www.open-open.com/bbs/view/1319816219625 http://my.oschina.net/yangsheng/blog/190917

  2. Mastering C# structs

    http://www.developerfusion.com/article/84519/mastering-structs-in-c/

  3. Favorite Games

    Samurai II: Vengeance: http://www.madfingergames.com/games

  4. 总结CSS面试题目的考察点及常见布局问题整理

    整理网上流传的若干份面试题目,突发奇想,总结关于CSS面试题目的考察点,发现问题大多围绕几个属性和几种题目,水平有限,仅供参考. 写这个博文内心有种莫名奇妙的自我谴责感,实在不应该把面试层叠样式“应试 ...

  5. PasswordHasher

    namespace Microsoft.AspNet.Identity { public class PasswordHasher : IPasswordHasher { public virtual ...

  6. ElasticSearch之一——索引

    ElasticSearch索引 ElasticSearch 是一个分布式可扩展的实时搜索引擎,它建立在开源搜索引擎框架Apache Lucene基础上.ElasticSearch 不但包括了全文搜索功 ...

  7. Java多线程编程核心技术---线程间通信(二)

    通过管道进行线程间通信:字节流 Java提供了各种各样的输入/输出流Stream可以很方便地对数据进行操作,其中管道流(pipeStream)是一种特殊的流,用于在不同线程间直接传送数据,一个线程发送 ...

  8. 我的J2EE学习历程

    由于最近手头没有JSP项目,所以暂停Hibernate和Spring的研究.个人觉得只有发现某个东西的不足之后再去学习新的东西来弥补这个不足比较好.就好比,最开始在JSP页面里面写Java代码,每次操 ...

  9. YII2操作mongodb笔记(转)

    componets配置: 'mongodb' => [ 'class' => '\yii\mongodb\Connection', 'dsn' => 'mongodb://test: ...

  10. CXF bus interceptor配置

    作用:BUS是cxf的支架,它主要担当扩展及拦截器提供者的角色. 在这里主要讲讲 bus的interceptor的功能 目前配置cxf的interceptor主要有2中方法: 1.通过xml配置文件的 ...