Ignatius and the Princess III

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 11810    Accepted Submission(s): 8362

Problem Description
"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!"

 
Input
The input contains several test cases. Each test case contains a positive integer N(1<=N<=120) which is mentioned above. The input is terminated by the end of file.
 
Output
For each test case, you have to output a line contains an integer P which indicate the different equations you have found.
 
Sample Input
4 10 20
 
Sample Output
5 42 627
 
Author
Ignatius.L
 

最简单的母函数模板题,用于学习和回顾母函数非常方便,代码也可直接做模板使用

 /*
hdu acm 1028 数字拆分,母函数模板题
by zhh
*/
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cstring> using namespace std;
#define maxx 120
int ans[maxx+],temp[maxx+];
void init()//母函数打表
{
for(int i=;i<=maxx;i++)//初始化第一个式子系数
{
ans[i]=;
temp[i]=;//用于临时保存每次相乘的结果
}
for(int i=;i<=maxx;i++)//循环每一个式子
{
for(int j=;j<=maxx;j++)//循环第一个式子各项
for(int k=;k+j<=maxx;k+=i)//下个式子的各项
temp[k+j]+=ans[j];//结果保存到temp数组中
for(int j=;j<=maxx;j++)//临时保存的值存入ans数组
{
ans[j]=temp[j];
temp[j]=;
}
}
}
int main()
{
init();
int n;
while(scanf("%d",&n)!=EOF)
{
cout<<ans[n]<<endl;
}
return ;
}

hdu acm 1028 数字拆分Ignatius and the Princess III的更多相关文章

  1. ACM学习历程—HDU1028 Ignatius and the Princess III(递推 || 母函数)

    Description "Well, it seems the first problem is too easy. I will let you know how foolish you ...

  2. Ignatius and the Princess III HDU - 1028 || 整数拆分,母函数

    Ignatius and the Princess III HDU - 1028 整数划分问题 假的dp(复杂度不对) #include<cstdio> #include<cstri ...

  3. HDU 1028 整数拆分问题 Ignatius and the Princess III

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

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

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

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

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

    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(DP)

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

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

  9. hdu 1028 Sample Ignatius and the Princess III (母函数)

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

随机推荐

  1. 如何得到EF(ADO.NET Entity Framework)查询生成的SQL? ToTraceString Database.Log

    ADO.NET Entity Framework ToTraceString  //输出单条查询 DbContext.Database.Log  //这里有详细的日志

  2. 可以让电脑卡机的c++程序

    #include <iostream> #include<windows.h> #include <shellapi.h> #include <stdio.h ...

  3. 转-servlet 获取 post body 体用流读取为空的问题

    目前基于rest风格的很多API开始使用通过body data来传输来代替之前的key-value传输方式.在Java servlet或者springmvc中可以通过如下代码来获取并图片通过流方式传输 ...

  4. Finereport集群配置

    增加配置文件cluster.xml 将配置包resource文件夹下的cluster.xml打开,如果没有cluster.xml,则新建一个,基本内容如下: <?xml version=&quo ...

  5. 利用GCTA工具计算复杂性状/特征(Complex Trait)的遗传相关性(genetic correlation)

    如文章"Genome-wide Complex Trait Analysis(GCTA)-全基因组复杂性状分析"中介绍的GCTA,是一款基于全基因组关联分析发展的分析工具,除了计算 ...

  6. Oracle 11g服务详细介绍及哪些服务是必须开启的?

    安装oracle 11g R2中的方法成功安装Oracle 11g后,共有7个服务,这七个服务的含义分别为: 1. Oracle ORCL VSS Writer Service:Oracle卷映射拷贝 ...

  7. [转] Oracle数据库备份与恢复 - 增量备份

    转:http://blog.csdn.net/pan_tian/article/details/46780929   RMAN一个强大的功能是支持增量备份,增量备份中心思想就是减少备份的数据量,我们不 ...

  8. 分析‖为什么越来越多厂商开始发力VR一体机?

    2015年下半年,国内VR头显市场的主旋律还是PC头显和手机盒子.到了2016年上半年,一体机逐渐上位,成为发布会上的主角. 近期IDEALENS启视在北京召开发布会,发布会的主角K2和K2Pro正是 ...

  9. Firefox每次刷新时自动清空缓存的设置方法

    当我们开发网页应用时候,为了保证每次看到的页面是最新的,需要在刷新页面时清除页面缓存. 如果每次都手动清除比较麻烦,好在多数浏览器都支持自动清除缓存的功能. IE下我们可以将缓存设置为"每次 ...

  10. 架​设​W​e​b​服​务​器

    服务器是网站的灵魂,是打开网站的必要载体.按照体系架构来区分,服务器主要分为非X86服务器.x86服务器.非X86服务器使用RISC(精简指令集)或EPIC(并行指令代码)处理器:X86服务器又称CI ...