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个区间 问你各个区间的总策略值最少的炸法 就题目本身而言,中规中矩的 ...
随机推荐
- 9月6日表格标签(table、行、列、表头)(补)
一.<table> <table>代表表格标签. <table></table> 1.width 表示表格宽度,宽度表达方式有像素和百分比两种.网 ...
- Java类集
类集就是一个动态的对象数组,是对一些实现好的数据结构进行了包装,这样在使用时就会非常方便,最重要的是类集框架本身不受对象数组长度的限制. 类集框架的主要接口
- php Hash Table(三) Hash Table初始化
HashTable初始化,在使用HashTable之前要先执行初始化,下边就看看初始化时都做了什么, Zend/zend_hash.c static const Bucket *uninitializ ...
- osharp3使用经验:整合DbContextScope 文章 1
osharp3的事务处理是跳过savechangeing方法来控制的,没有DbContextScope专业 DbContextScope管理dbcontext的优劣本文不讨论 整合过程: 1.在.Da ...
- jQuery简单实现iframe的高度根据页面内容自适应的方法
同域下: //注意:下面的代码是放在和iframe同一个页面中调用 $("#myiframe").load(function () { var myiframeH = $(this ...
- Yii2 事务
$transaction = $connection->beginTransaction(); try { // ... executing other SQL statements ... $ ...
- django,python,svn_web
- 图书管理系统——APP平台开发
http://www.w3school.com.cn/php/ 初步计划采用PHP 开发网站. 一定要独立建立一套图书管理系统, 尤其唯一性质的概念,整合,甚至中英文图书概念的而整合.一本书一个页. ...
- jquery mobile常用的data-role类型 data-icon data-iconpos
文章链接: http://blog.csdn.net/cainiaoxiaozhou/article/details/48521241
- Cannot install NodeJs: /usr/bin/env: node: No such file or directory
安装doxmate时,doxmate地址是:https://github.com/JacksonTian/doxmatenpm install doxmate -g 安装完后把错误:Cannot in ...