B - The Staircases (dp)
One curious child has a set of N little bricks. From these bricks he builds different staircases. Staircase consists of steps of different sizes in a strictly descending order. It is not allowed for staircase to have steps equal sizes. Every staircase consists of at least two steps and each step contains at least one brick. Picture gives examples of staircase for N=11 and N=5:
Your task is to write a program that reads from input numbers N and writes to output numbers Q - amount of different staircases that can be built from exactly N bricks.
Input
Numbers N, one on each line. You can assume N is between 3 and 500, both inclusive. A number 0 indicates the end of input.
<b< dd="">Output
Numbers Q, one on each line.
<b< dd="">Sample Input
3 
5 
0
状态转移方程:dp[i][j]=dp[i-j][j-1]+dp[i][j-1];
注意开数组不要太大,可能会T
代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<cmath> const int maxn=1e5+;
typedef long long ll;
using namespace std;
ll dp[][];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
if(n==)
break;
memset(dp,,sizeof(dp));
for(int i=;i<=n;i++)
dp[][i]=;
for(int i=;i<=n;i++)
for(int j=;j<=n;j++)
if(i>=j)
dp[i][j]=dp[i-j][j-]+dp[i][j-];
else
dp[i][j]=dp[i][j-];
printf("%lld\n",dp[n][n]-);
}
return ;
}
B - The Staircases (dp)的更多相关文章
- ural 1017. Staircases(dp)
		
http://acm.timus.ru/problem.aspx?space=1&num=1017 题意:有n块砖,要求按照严格递增的个数摆放成楼梯,求楼梯的摆放种类数. 思路:状态转移方程: ...
 - 递推DP URAL 1017 Staircases
		
题目传送门 /* 题意:给n块砖头,问能组成多少个楼梯,楼梯至少两层,且每层至少一块砖头,层与层之间数目不能相等! 递推DP:dp[i][j] 表示总共i块砖头,最后一列的砖头数是j块的方案数 状态转 ...
 - BZOJ 1911: [Apio2010]特别行动队 [斜率优化DP]
		
1911: [Apio2010]特别行动队 Time Limit: 4 Sec Memory Limit: 64 MBSubmit: 4142 Solved: 1964[Submit][Statu ...
 - 2013 Asia Changsha Regional Contest---Josephina and RPG(DP)
		
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4800 Problem Description A role-playing game (RPG and ...
 - AEAI DP V3.7.0 发布,开源综合应用开发平台
		
1 升级说明 AEAI DP 3.7版本是AEAI DP一个里程碑版本,基于JDK1.7开发,在本版本中新增支持Rest服务开发机制(默认支持WebService服务开发机制),且支持WS服务.RS ...
 - AEAI DP V3.6.0 升级说明,开源综合应用开发平台
		
AEAI DP综合应用开发平台是一款扩展开发工具,专门用于开发MIS类的Java Web应用,本次发版的AEAI DP_v3.6.0版本为AEAI DP _v3.5.0版本的升级版本,该产品现已开源并 ...
 - BZOJ 1597: [Usaco2008 Mar]土地购买 [斜率优化DP]
		
1597: [Usaco2008 Mar]土地购买 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 4026 Solved: 1473[Submit] ...
 - [斜率优化DP]【学习笔记】【更新中】
		
参考资料: 1.元旦集训的课件已经很好了 http://files.cnblogs.com/files/candy99/dp.pdf 2.http://www.cnblogs.com/MashiroS ...
 - BZOJ 1010: [HNOI2008]玩具装箱toy [DP 斜率优化]
		
1010: [HNOI2008]玩具装箱toy Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 9812 Solved: 3978[Submit][St ...
 
随机推荐
- Windows系统护眼色设置
			
Win10&Win8系统设置护眼色1. windows+R键调出运行窗口(或者鼠标右击开始键,选择运行)2. 在运行窗口中输入 regedit 调出注册表编辑器3. 按照如下顺序找到windo ...
 - ACL2020  Contextual Embeddings When Are They Worth It 精读
			
上下文嵌入(Bert词向量): 什么时候值得用? ACL 2018 预训练词向量 (上下文嵌入Bert,上下文无关嵌入Glove, 随机)详细分析文章 1 背景 图1 Bert 优点 效果显著 缺点 ...
 - beyond compare4 密钥 亲测可用
			
beyond compare4过了试用期: 密钥: w4G-in5u3SH75RoB3VZIX8htiZgw4ELilwvPcHAIQWfwfXv5n0IHDp5hv1BM3+H1XygMtiE0-J ...
 - IDEA-Translation最优秀的翻译插件
			
IDEA最优秀的翻译插件 效果 特性 多翻译引擎 Google翻译 有道翻译 百度翻译 多语言互译 文档翻译 语音朗读 自动选词 自动单词拆分 单词本 使用 申请有道智云翻译服务(可选): 注册有道智 ...
 - python3.2求和与最值
			
#1到100求和sum1=0for x in range(101): sum1=sum1+xprint(sum1) #1到100偶数求和sum2=0for x in range(0,101,2): p ...
 - 记Java中有关内存的简单认识
			
一.Java内存划分 分为五个部分,可以参考这篇笔记简单认识一下: https://www.cnblogs.com/unleashed/p/13268027.html 栈 堆 方法区 本地方法栈 寄存 ...
 - JQury的选择器
			
jQuery 的选择器可谓之强大无比,这里简单地总结一下常用的元素查找方法 $("#myELement") 选择id值等于myElement的元素,id值不能重复在文档中只能有一个 ...
 - 9、Java 常用类 Math,Number子类,String,Character
			
本小节主要介绍一些如何去使用Java提供的类如何去使用?如何在实战中使用?从来没有用过的如何去学习? 分享一下发哥的学习方法? 1.针对性的学习 在理解自己的需求或者要做某一块的内容后,有针对性,选择 ...
 - Kubernetes 使用arthas进行调试
			
环境 因为k8s中是最基本的jre,网上说缺少tools.jar,但是补充了以后还是不行,最后还是将整个jdk给移到容器中的. jre中执行: /home # /opt/jre/bin/java -j ...
 - C#设计模式之12-代理模式
			
代理模式(Proxy Pattern) 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/411 访问. 代理模式属于结构型 ...