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个区间 问你各个区间的总策略值最少的炸法 就题目本身而言,中规中矩的 ...
随机推荐
- 20145212 实验四《Andoid开发基础》
20145212 实验四<Andoid开发基础> 实验内容 安装Android Studio 运行安卓AVD模拟器 使用Android运行出模拟手机并显示自己的学号 实验过程 一.安装An ...
- Java对象的多态性(转型)
多态性在面向对象中主要有两种体现: <1>方法的重载与覆写 <2>对象的多态性 对象的多态性:向上转型:子类对象-->父类对象,向上转型会自动完成 向下转型:父类对象-- ...
- 有了这个,再也不用每次连新机器都要设置secure crt属性了
我连服务器用的是secure crt,每次ssh新服务器的时候都得手动设置字符编码和背景颜色,今天问了旁边的开发原来可以全局设置,以后连服务器的时候就再也不用手动设置相关属性了.步骤如下: 一开始点击 ...
- GMU 简单使用一
<!doctype html> <html> <head> <title>iOS7风格的进度条</title> <meta chars ...
- python错误
1.IndentationError: unindent does not match any outer indentation level 原因:一般是代码没有对齐 参考网址: http: ...
- NoSQL 简介及什么是AICD
NoSQL 简介 NoSQL(NoSQL = Not Only SQL ),意即"不仅仅是SQL". 在现代的计算系统上每天网络上都会产生庞大的数据量. 这些数据有很大一部分是由关 ...
- CPC CPM
计算广告的分类: 根据广告主的计费方式,可以分为 千次展现付费 CPM(cost per thousand impressions) 主要用于品牌曝光,例如钻展业务 每次点击扣费 CPC(cost p ...
- C#程序
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net ...
- 新浪微博客户端(59)-hitTest withEvent方法的使用说明
iOS中的触摸事件总是由最顶层的View首先得到的,当这个View得到该触摸事件的时候可以选择通过 - (BOOL)pointInside:(CGPoint)point withEvent:(UIEv ...
- post、get的区别
get的参数会显示在浏览器地址栏中,而 post的参数不会显示在浏览器地址栏中: 使用 post提交的页面在点击[刷新]按钮的时候浏览器一般会提示“是否重新提交”,而 get则不会: 用get的页面可 ...