Ignatius and the Princess III

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

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
 
 #include <stdio.h>
int main()
{
int i,j,k,n;
int c1[],c2[];
while(scanf("%d",&n)!=EOF)
{
for(i=;i<=n;i++)
{
c1[i]=;
c2[i]=;
}
for(i=;i<=n;i++)
{
for(j=;j<=n;j++)
for(k=;k+j<=n;k+=i)
{
c2[k+j]+=c1[j];
}
for(j=;j<=n;j++)
{
c1[j]=c2[j];
c2[j]=;
}
}
printf("%d\n",c1[n]);
}
return ;
}

hdu_1028_Ignatius and the Princess III的更多相关文章

  1. hdu acm 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)

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

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

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

  4. HDU 1028Ignatius and the Princess III(母函数简单题)

     Ignatius and the Princess III Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

  5. HDOJ 1028 Ignatius and the Princess III (母函数)

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

  6. HDU1028 Ignatius and the Princess III 【母函数模板题】

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

  7. Ignatius and the Princess III

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

  8. Ignatius and the Princess III --undo

    Ignatius and the Princess III Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (J ...

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

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

随机推荐

  1. AJPFX编写cmd界面下一键编译、执行java代码的bat脚本

    此脚本适合刚接触java的同学,在cmd界面下用jc取代 复杂的  javac *.java + java main使用说明:把脚本内容复制到txt文本中,修改后缀名为.bat,运行一次即可完成配置, ...

  2. LitePal用法详解

    一.首先我对数据库的操作基于LitePal的,是基于面向对象思想的,所以首先我先讲怎么使用LitePal 1.在build.garde(Module:app)里面的 dependencies{ //添 ...

  3. thinkphp查询,3.X 5.0 亲试可行

    [php] view plain copy   print? 一.介绍 ThinkPHP内置了非常灵活的查询方法,可以快速的进行数据查询操作,查询条件可以用于读取.更新和删除等操作,主要涉及到wher ...

  4. 重构29-Remove Middle Man(去掉中间人)

    有时你的代码里可能会存在一些"Phantom"或"Ghost"类,Fowler称之为"中间人(Middle Man)".这些中间人类仅仅简单 ...

  5. 用yunio网盘搭建git私有仓库

      研究生开始奔波于教研室和寝室之间,于是想搭建一个git私有仓库来管理自己在做的项目或者学习资料.一来可以很方便的管理项目,二来可以学习使用git.我的主要工作平台是Linux,这也是我选择yuni ...

  6. schtasks /create 计划任务 中文路径 名字都要加“” 子命令 /tn /tr 前面要空格 否则会出错

    echo off echo. 清空连接 net use * /del /y echo. 连接 net use \\192.168.1.2\人力资源部\考勤\考勤数据-小莫提供 "密码&quo ...

  7. C/C++ 函数模板、全局变量、register、存储周期

    1.函数声明时可以简写,如: int max(int,int): 2.函数模板: 格式: template <typename haha>或template <class haha& ...

  8. 谷歌全屏脚本 start chrome.exe --kiosk http://www.baidu.com

    start chrome.exe --kiosk http://www.baidu.com

  9. hdfs深入:09、获取分布式文件系统客户端的几种方式

    FileSystem是一个抽象类:获取一个抽象类有两种方式:第一种:看这个抽象类有没有提供什么方法返回他本身第二种:找子类 具体代码如下: /** * 通过url注册的方式访问hdfs,了解,不会用到 ...

  10. 运用 node + express + http-proxy-middleware 实现前端代理跨域的 详细实例哦

    一.你需要准备的知识储备 运用node的包管理工具npm 安装插件.中间件的基本知识: 2.express框架的一些基础知识,知道如何建立一个小的服务器:晓得如何快速的搭建一个express框架小应用 ...