hdu1028
#include<stdio.h>
#include<string.h>
const int MAXN=130;
int dp[MAXN][MAXN];
//dp[i][j]表示 i 表示成最大的数不超过 j 的方法数
int calc(int n,int m)
{
if(dp[n][m]!=-1) return dp[n][m];
if(n<1||m<1) return dp[n][m]=0;
if(n==1||m==1) return dp[n][m]=1;
if(n<m) return dp[n][m]=calc(n,n);
if(n==m) return dp[n][m]=calc(n,m-1)+1;
return dp[n][m]=calc(n,m-1)+calc(n-m,m);
}
int main()
{
int n;
memset(dp,-1,sizeof(dp));
while(scanf("%d",&n)!=EOF)
printf("%d\n",calc(n,n));
return 0;
}
hdu1028的更多相关文章
- hdu1028 Ignatius and the Princess III
这是道典型的母函数的题目,可以看看我的母函数这一标签上的另一道例题,里面对母函数做了较为详细的总结.这题仅贴上代码: #include"iostream" using namesp ...
- HDU1028 Ignatius and the Princess III 【母函数模板题】
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- hdu1028:整数拆分
求整数的拆分数.. 一种解法是母函数 #include <iostream> #include <stdio.h> #include<string.h> #incl ...
- hdu1028(整数划分问题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028 整数划分问题 整数划分 --- 一个老生长谈的问题: 描述 整数划分是一个经典的问题.请写一个程 ...
- 【转】HDU1028
转自博客园ID:2108,老卢同志 http://www.cnblogs.com/--ZHIYUAN/p/6102893.html Ignatius and the Princess III Time ...
- HDU1028【母函数】
题目:给你数n,问n可以有哪些组成方案(这些n的数字个数不超过n),母函数模板题 #include <cstdio> #include <cstring> #include & ...
- HDU-1028 Ignatius and the Princess III(生成函数)
题意 给出$n$,问用$1$到$n$的数字问能构成$n$的方案数 思路 生成函数基础题,$x^{n}$的系数即答案. 代码 #include <bits/stdc++.h> #define ...
- hdu1028 Ignatius and the Princess III(生成函数整理占坑)upd 已咕
先咕着 ---------------2018 5 22---------------------- 题解 生成函数处理整数拆分 code #include<cstdio> #includ ...
- HDU1028 (整数拆分)
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
随机推荐
- MVC中验证码
MVC中验证码的实现(经常用,记录备用) 一.目录 1.多层架构+MVC+EF+AUTOFAC+AUTOMAPPER: 2.MVC中验证码的实现(经常用,记录备用) 3.Ligerui首页的快速搭 ...
- 【ios开发】ios开发问题集锦
1. ARC forbids explicit message send of'release' 'release' is unavailable: not available inautomatic ...
- Azure的两种关系型数据库服务:SQL Azure与SQL Server VM的不同
Azure的两种关系型数据库服务:SQL Azure与SQL Server VM的不同 <Windows Azure Platform 系列文章目录> 如果熟悉Windows Azure平 ...
- D12
orz!=-=今天莫名爆人品..表示受到了惊吓.. 一下子从rank20-30+,突然间蹦到了rank3..=-=可怕.. 或许是因为T1有看过啊类似的啊..然后T3又被40指点了一下,T2打了个暴力 ...
- discuz 门户功能增加自定义keywords字段
discuz的门户的“发布文章”功能中,没有自动添加keywords字段,结果在文章页面中的meta的keywords中只显示标题,这样对于seo及其不利,今天整理了添加keywords字段方法. 一 ...
- Leetcode:Minimus Depth of Binary Tree
The problem description: Given a binary tree, find its minimum depth. The minimum depth is the numbe ...
- 调用MobileAPI的设计(iOS篇)
调用MobileAPI的设计(iOS篇) 这一节讲如何发起网络请求. iOS用于调用MobileAPI的第三方组件很多,我们这里采用的是以下组件: 1)ASIHTTPRequest,用于请求Mobil ...
- 基于ReliefF和K-means算法的医学应用实例
基于ReliefF和K-means算法的医学应用实例 数据挖掘方法的提出,让人们有能力最终认识数据的真正价值,即蕴藏在数据中的信息和知识.数据挖掘 (DataMiriing),指的是从大型数据库或数据 ...
- WebApp之PC客户端
开发WebApp之PC客户端 HTML5的跨平台性还是很好的,苹果.Android手机都可以用,所在最近使用Jquery Mobile开发了一个手机端应用程序,一次开发,多个平台使用. 但我们的很多客 ...
- BizTalk 2010/2013 EDI B2B
BizTalk 2010/2013 EDI B2B项目实践(1) BizTalk 2010/2013 EDI B2B项目实践(1) BizTalk开发标准EDI B2B是件非常容易的事情,但对于初 ...