HDU-1028-Ignatius and the Princess III(母函数)
链接:
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(母函数)的更多相关文章
- 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 = ...
随机推荐
- [转帖]鲁大师Q3季度PC处理器排行:AMD、Intel终于五五开了
鲁大师Q3季度PC处理器排行:AMD.Intel终于五五开了 https://www.cnbeta.com/articles/tech/902375.htm 近日,鲁大师发布了Q3季度PC处理器排行. ...
- springMVC设置不拦截静态资源的方法
SpringMVC提供<mvc:resources>来设置静态资源,但是增加该设置如果采用通配符的方式增加拦截器的话仍然会被拦截器拦截,可采用如下方案进行解决: 方案一.拦截器中增加针对静 ...
- 关于tomcat9的startup.bat闪退问题&乱码
1.打开apache-tomcat-9.0.22的bin目录 选择图中文件 记事本打开 2.更改文件 setclasspath.bat .0_172\jre 3.保存 startup ----- ...
- 多线程(8) — ThreadLocal
ThreadLocal是一个线程的局部变量,也就是只有当前线程可以访问,是线程安全的.为每一个线程分配不同的对象,需要在应用层面保证ThreadLocal只起到简单的容器作用. ThreadLocal ...
- Python-18-类的内置属性
1. __getattr__.set__attr__.__delattr__ class Foo: x=1 def __init__(self,y): self.y=y def __getattr__ ...
- Linux的常用命令及快捷键
常用快捷键 1 终端中的快捷键 ctrl+a 回到行首,ctrl+e回到行尾 ctrl+n 代码候选 常用命令
- 【HC89S003F4开发板】 4端口消抖
HC89S003F4开发板端口消抖 一.前言 看到资料里有中断消抖的例子,因为以前项目里有遇到高频干扰频繁退出休眠的情况,所以好奇用这个配置能不能解决. 二.对demo进行修改 @实现效果 P01设置 ...
- PB自动换行
1.在DataWindow Painter中打开DataWindow; 2.在需设定自动折行的列上单击, 查看右侧的属性窗口: 3.点击Position标签, 选中Autosize Height 多选 ...
- IO是否会一直占用CPU?(转)
原文来自知乎:https://www.zhihu.com/question/27734728 这是一个很好的关于并发/并行系统的问题.简单回答就是:IO所需要的CPU资源非常少.大部分工作是分派给DM ...
- Spring Cloud Alibaba学习笔记(13) - Spring Cloud Stream的监控与异常处理
Spring Cloud Stream监控 Spring Boot Actuator组件用于暴露监控端点,很多监控工具都需要依赖该组件的监控端点实现监控.而项目集成了Stream及Actuator后也 ...