题意:

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(母函数)的更多相关文章

  1. hdu 1028 Ignatius and the Princess III 母函数

    Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  2. hdu 1028 Ignatius and the Princess III 简单dp

    题目链接:hdu 1028 Ignatius and the Princess III 题意:对于给定的n,问有多少种组成方式 思路:dp[i][j],i表示要求的数,j表示组成i的最大值,最后答案是 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. HDU 1028 Ignatius and the Princess III (生成函数/母函数)

    题目链接:HDU 1028 Problem Description "Well, it seems the first problem is too easy. I will let you ...

  8. HDU 1028 Ignatius and the Princess III (递归,dp)

    以下引用部分全都来自:http://blog.csdn.net/ice_crazy/article/details/7478802  Ice—Crazy的专栏 分析: HDU 1028 摘: 本题的意 ...

  9. HDU 1028 Ignatius and the Princess III (动态规划)

    题目链接:HDU 1028 Problem Description "Well, it seems the first problem is too easy. I will let you ...

  10. HDU 1028 Ignatius and the Princess III:dp or 母函数

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028 题意: 给你一个正整数n,将n拆分成若干个正整数之和,问你有多少种方案. 注:"4 = ...

随机推荐

  1. 学习PHP中统计扩展函数的使用

    做统计相关系统的朋友一定都会学习过什么正态分布.方差.标准差之类的概念,在 PHP 中,也有相应的扩展函数是专门为这些统计相关的功能所开发的.我们今天要学习的 stats 扩展函数库就是这类操作函数. ...

  2. [原创]OpenEuler20.03安装配置PostgreSQL13.4详细图文版

    OpenEuler安装配置PostgreSQL 编写时间:2021年9月18日 作者:liupp 邮箱:liupp@88.com 序号 更新内容 更新日期 更新人 1 完成第一至三章内容编辑: 202 ...

  3. Jmeter系列(7)- 分析源码,创建下单、用户注销接口请求

    源码分析 下单 用户注销 创建请求 下单 用户注销 请求调整 将信息头管理器从[02.浏览订单]请求中抽出来就变成公用的.[03,04]请求不需要单独再加信息头管理器 DeBug取样器 添加DeBug ...

  4. Linux系列(36) - yum命令安装(3)

    yum常用命令 查询 yum list:查询所有可用软件包列表 yum search 关键字:搜索服务器上所有和关键字相关的包 安装 yum -y install 包名 选项: -install 安装 ...

  5. Writing in the Science 01

    INTRODUCTION What makes good writing? Good writing communicates an idea clearly and effectively. Goo ...

  6. javascript / PHP [Design Patterns - Facade Pattern]

    This pattern involves a single class which provides simplified methods required by client and delega ...

  7. P3980-[NOI2008]志愿者招募【费用流】

    正题 题目链接:https://www.luogu.com.cn/problem/P3980 题目大意 \(n\)天,第\(i\)天需要\(A_i\)个志愿者.有\(m\)种志愿者,第\(i\)种从\ ...

  8. Java中的引用类型和使用场景

    作者:Grey 原文地址:Java中的引用类型和使用场景 Java中的引用类型有哪几种? Java中的引用类型分成强引用, 软引用, 弱引用, 虚引用. 强引用 没有引用指向这个对象,垃圾回收会回收 ...

  9. Unity——可复用背包工具

    Unity可复用背包工具 Demo展示 设计思路 游戏中有非常多的背包样式,比如玩家道具背包,商城,装备栏,技能栏等:每个形式的背包都单独写一份逻辑会非常繁琐,所以需要有一套好用的背包工具: 这些背包 ...

  10. C++默认参数静态绑定

    先来看这样一段代码 class Base { public: virtual void print(int a = 1) const { std::cout << "Base & ...