链接:

https://vjudge.net/problem/HDU-1028

题意:

"Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says.

"The second problem is, given an positive integer N, we define an equation like this:

N=a[1]+a[2]+a[3]+...+a[m];

a[i]>0,1<=m<=N;

My question is how many different equations you can find for a given N.

For example, assume N is 4, we can find:

4 = 4;

4 = 3 + 1;

4 = 2 + 2;

4 = 2 + 1 + 1;

4 = 1 + 1 + 1 + 1;

so the result is 5 when N is 4. Note that "4 = 3 + 1" and "4 = 1 + 3" is the same in this problem. Now, you do it!"

思路:

母函数模板题。

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector> using namespace std;
typedef long long LL;
const int INF = 1e9; const int MAXN = 120+10;
int c1[MAXN], c2[MAXN];
int n; void Init()
{
c1[0] = 1;
for (int i = 1;i < MAXN;i++)
{
for (int j = 0;j < MAXN;j+=i)
{
for (int k = 0;k+j < MAXN;k++)
c2[j+k] += c1[k];
}
for (int j = 0;j < MAXN;j++)
{
c1[j] = c2[j];
c2[j] = 0;
}
}
} int main()
{
Init();
while(~scanf("%d", &n))
{
printf("%d\n", c1[n]);
} return 0;
}

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. C++ 生成随机数总结 & C++ rand 函数使用方法

    1. 产生[0,b]之间的随机数 rand()*b / RAND_MAX; 2. 产生[-a,0]之间的随机数 rand()*(-a) / RAND_MAX; 3. 产生[a,b]之间的随机数 a + ...

  2. Django使用指南

    一.安装Django 1.命令行安装 pip3 install django(默认安装最新稳定版本) pip3 install django==版本号(指定版本安装) 2.Pycharm安装 在Pyc ...

  3. Java同C#的语法不同之处

    Java同C#的语法不同之处... [注:转载而来但原出处不详:若是您原创请联系我]1,命名空间与包 C#为了把实现相似功能的类组织在一起,引入了命名空间的概念(namespace) Java中与此对 ...

  4. Kubernetes 常见错误

    OOMKilled: Pod 的内存使用超出了 resources.limits 中的限制,被强制杀死. CrashLoopBackoff: Pod 进入 崩溃-重启循环,重启间隔时间从 10 20 ...

  5. win10 idea springboot上传镜像到远程docker服务器

    1. 开启2375端口,供外部访问docker vim /usr/lib/systemd/system/docker.service 修改ExecStart为下面一行内容 #ExecStart=/us ...

  6. git创建本地分支,推送到远程

    创建本地分支git branch 分支名 例如:git branch dev,这条命令是基于当前分支创建的本地分支,假设当前分支是master(远程分支),则是基于master分支创建的本地分支dev ...

  7. AVOSCloud入门教程:Android Parse云服务的Hello World

    本文时间戳:2013年8月30日 AVOSCloud(万象云)才刚刚推出来不久的咯,其背后创业的推动者据说是Youtube的华人老大陈士骏(SteveChen,貌似手头有很多创业,美味,玩拍,都是,开 ...

  8. WinForm 无焦点获取键盘输入

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...

  9. IServiceBehavior IContractBehavior IEndpointBehavior IOperationBehavior

    using System; using System.Collections.ObjectModel; using System.Reflection; using System.ServiceMod ...

  10. 日常hive遇到的问题

    1 hive中的复杂数据类型数据如何导入(array) 创建hive表 create table temp.dws_search_by_program_set_count_his( program_s ...