Ignatius and the Princess III
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 16918 Accepted Submission (s): 11907
Problem Description "Well, it seems the first problem are too easy. I'll let you know how foolish is later. "feng5166 says.
"The second problem is, given an positive integer N, we define a equation like this:
N=A[1]+A[2]+A[3]+...+A[M];
a[i]>0,1<=m<=n;
My question is what 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;
The result is 5 while N is 4. Note that "4 = 3 + 1" and "4 = 1 + 3" are the same in this problem. Now, do it! "
Inputthe input contains several test cases. Each test case contains a positive an integer N (1<=n<=120) which is mentioned above. The input is terminated by the end of file.
Outputfor each of the test case and you had to output a line contains an integer P which indicate the different equations you had Found.
Sample Input41020
Sample Output542627
Authorignatius.l
Recommendwe has carefully selected several similar problems for you:1171 1085 1398 2152 1709 the problem of integer partitioning is the same as the one I wrote earlier, for reference: Http://www.cnblogs.com/pshw/p/4838898.html However, this data is relatively large, and direct recursive computations result in timeouts, so the idea of using a parent function is required. In fact, I do not know what is called the mother function ... Just save the data with DP. Test instructions: Integer partitioning is the problem of splitting a positive integer n into a group of numbers that are equal to n, and that the maximum addend in this set of numbers is not greater than N. Attached code:
1#include <iostream>2#include <cstdio>3#include <cstring>4 using namespacestd;5 intMain ()6 {7 intn,i,j,m;8 intdp[ the][ the];9Memset (DP,0,sizeof(DP));Tendp[1][1]=1; One for(i=1; i<= -; i++) A { -dp[i][1]=1; -dp[1][i]=1; the } - for(i=2; i<= -; i++)//the rules can be seen recommended blog ~ - { - for(j=2; j<= -; J + +) + { - if(j>i) +dp[i][j]=Dp[i][i]; A Else if(i==j) atdp[i][j]=dp[i][j-1]+1; - Else -dp[i][j]=dp[i][j-1]+dp[i-J] [j]; - } - } - while(~SCANF ("%d",&N)) in { -printf"%d\n", Dp[n][n]); to } + return 0; -}
HDU 1028 Ignatius and the Princess III