Ignatius and the Princess III

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 16122    Accepted Submission(s): 11371

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

/*#include<stdio.h>
#include<string.h>
int dp[1000][1000],n;
int main()
{
while(scanf("%d",&n)!=EOF)
{
memset(dp,0,sizeof(dp));
for(int i=1;i<1000;i++)
dp[i][1]=dp[1][i]=1;
for(int i=2;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(i>j) dp[i][j]=dp[i-j][j]+dp[i][j-1];
else if(i==j) dp[i][j]=dp[i][j-1]+1;
else dp[i][j]=dp[i][i];
}
}
printf("%d\n",dp[n][n]);
}
return 0;
}*/
#include<stdio.h>
#include<string.h>
int dp[1200];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
memset(dp,0,sizeof(dp));
dp[0]=1;
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j++)
{
dp[j]+=dp[j-i];
}
printf("%d\n",dp[n]);
}
}

最新文章

  1. 多线程并发同一个表问题(li)
  2. BI建模原则和常见问题
  3. 解决git pull 命令失效,不能从远程服务器上拉取代码问题
  4. Java 7 Concurrency Cookbook 翻译 第一章 线程管理之四
  5. SVN 远程无法联通
  6. 【Win10】让 AppBarButton 支持更复杂的 Icon 内容
  7. 列出当前ARM开发板系统加载的模块
  8. Docker基础技术:Linux CGroup
  9. UFLDL课程学习(二)
  10. Android在WebView上构建Web应用程序
  11. Android Realm数据库使用指南
  12. 小强的Hadoop学习之路
  13. sql 存储过程学习
  14. Mongo C# Driver 聚合使用---深入浅出
  15. git命令提交新项目
  16. ACE侧边栏刷新自动展开之前的选择
  17. ubuntu完全卸载mysql
  18. 【原创】Linux基础之windows linux双系统
  19. HTN规划 jshop2
  20. vue:vue-resource

热门文章

  1. [转]ORACLE EXECUTE IMMEDIATE 小结
  2. windows phone控件
  3. P1146 硬币翻转
  4. backface-visibility当元素不面向屏幕时是否可见
  5. System.DateTime.Now 24小时制。
  6. Scala——面向对象和函数式编程语言
  7. Hive2.1.1集群搭建
  8. Java_Web之状态管理
  9. 【C++】颜色的设置
  10. Firebug全了解