hdu 1028 Ignatius and the Princess III(母函数)
题意:
N=a[1]+a[2]+a[3]+...+a[m];
a[i]>0,1<=m<=N;
例如:
4 = 4;
4 = 3 + 1;
4 = 2 + 2;
4 = 2 + 1 + 1;
4 = 1 + 1 + 1 + 1;
共有5种。
给N,问共有几种构造方式。
思路:
一个数N分解的式子中1的个数可以是0,1,2,3,...,N。
2的个数可以是0,1,2,...,N/2。
....
母函数基础题,,
看代码。
当然也可以用DP(背包)
母函数代码:
int N,num;
int a[200],b[200]; int main(){
while(cin>>N){
memset(a,0,sizeof(a)); a[0]=1; memset(b,0,sizeof(b));
for(int i=1;i<=N;++i){
for(int j=0;j<=N;++j)
for(int k=0;k+j<=N;k+=i) b[j+k]+=a[j];
for(int j=0;j<=N;++j){ a[j]=b[j]; b[j]=0; }
}
cout<<a[N]<<endl;
}
}
hdu 1028 Ignatius and the Princess III(母函数)的更多相关文章
- hdu 1028 Ignatius and the Princess III 母函数
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- hdu 1028 Ignatius and the Princess III 简单dp
题目链接:hdu 1028 Ignatius and the Princess III 题意:对于给定的n,问有多少种组成方式 思路:dp[i][j],i表示要求的数,j表示组成i的最大值,最后答案是 ...
- HDU 1028 Ignatius and the Princess III 整数的划分问题(打表或者记忆化搜索)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1028 Ignatius and the Princess III Time Limit: 2000/1 ...
- HDU 1028 Ignatius and the Princess III (母函数或者dp,找规律,)
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- hdu 1028 Ignatius and the Princess III(DP)
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- hdu 1028 Ignatius and the Princess III (n的划分)
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- HDU 1028 Ignatius and the Princess III (生成函数/母函数)
题目链接:HDU 1028 Problem Description "Well, it seems the first problem is too easy. I will let you ...
- HDU 1028 Ignatius and the Princess III (递归,dp)
以下引用部分全都来自:http://blog.csdn.net/ice_crazy/article/details/7478802 Ice—Crazy的专栏 分析: HDU 1028 摘: 本题的意 ...
- HDU 1028 Ignatius and the Princess III (动态规划)
题目链接:HDU 1028 Problem Description "Well, it seems the first problem is too easy. I will let you ...
- HDU 1028 Ignatius and the Princess III:dp or 母函数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028 题意: 给你一个正整数n,将n拆分成若干个正整数之和,问你有多少种方案. 注:"4 = ...
随机推荐
- java web利用jsp完成简单的学生管理系统
index.jsp <%@ page language="java" import="java.sql.*" pageEncoding="utf ...
- 【OI】WERTYU UVa 10082
题目: A common typing error is to place the hands on the keyboard one row to the right of the correct ...
- Kubernetes-Pod介绍(三)-Pod调度
前言 本篇是Kubernetes第六篇,大家一定要把环境搭建起来,看是解决不了问题的,必须实战. Kubernetes系列文章: Kubernetes介绍 Kubernetes环境搭建 Kuberne ...
- 手把手教你实现栈以及C#中Stack源码分析
定义 栈又名堆栈,是一种操作受限的线性表,仅能在表尾进行插入和删除操作. 它的特点是先进后出,就好比我们往桶里面放盘子,放的时候都是从下往上一个一个放(入栈),取的时候只能从上往下一个一个取(出栈), ...
- 5ucms静态发布卡住解决办法
找到admin/admin_createhtml.asp文件(admin目录为你的后台管理目录),讲下面这段代码删掉保存即可. <script language="JavaScript ...
- 封装excel导出方法
封装读取excel内容方法 /** * 获取Excel内容 * @param type $filename * @return type */ public function getExcelCont ...
- 字体小于12px 无法缩小解决方案
通过缩放进行大小控制. 缩放可能会导致元素也进行缩放.需要注意 transform: scale(0.5);
- Python语句,表达式的区别?
参考了网上的文章,说 表达式的结果是值,对象 比如1+2, 是表达式 具体根据运算符不同有算术,逻辑,比较等等类型的表达式 语句是控制程序走向,不产生值 例如if/else等 参考: https:// ...
- 鸿蒙内核源码分析(内存分配篇) | 内存有哪些分配方式 | 百篇博客分析OpenHarmony源码 | v11.02
百篇博客系列篇.本篇为: v11.xx 鸿蒙内核源码分析(内存分配篇) | 内存有哪些分配方式 | 51.c.h .o 内存管理相关篇为: v11.xx 鸿蒙内核源码分析(内存分配篇) | 内存有哪些 ...
- SVN--代码状态检查(图文并茂)
接下来,我们用客户端去检出代码,在桌面空白处单击右键,选择SVN检出(check out),在弹出的对话框中填写版本库URL(具体获取方式,上面讲上传项目到版本库的时候讲过),选择检出目录,点击确定. ...