HDU 1028 (primary function), hdu1028 Function
|
Online Judge |
Online Exercise |
Online Teaching |
Online Contests |
Exercise Author |
F. A. Q Hand In Hand Online Acmers Forum | Discuss Statistical Charts |
|
|
Best Coder beta VIP | STD Contests Virtual Contests DIY | Web-DIY beta Recent Contests |
Jxust hsy Mail 0 (0) Control Panel Sign Out |
|
|
Ignatius and the Princess IIITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission (s): 19181 Accepted Submission (s): 13477
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! " InputThe 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. OutputFor each test case, you have to output a line contains an integer P which indicate the different equations you have found. Sample input000020 Sample Output542627 |
Question: How many different sharding methods are there?
# Include <bits/stdc ++. h> using namespace std; int c1 [205], c2 [205]; // c1 is used to record the coefficients before each item. c2 is used to record the median int main () {int n; while (~ Scanf ("% d", & n) {// There are n parentheses in total. Handle the first bracket first, and the coefficient of each item in the first bracket is 1; for (int I = 0; I <= n; I ++) {c1 [I] = 1; c2 [I] = 0 ;}// because there are n parentheses in total, I indicates processing the I-th parenthesis for (int I = 2; I <= n; I ++) {// j indicates that the nth item in the parentheses (I) is being processed. for (int j = 0; j <= (n); j ++) {for (int k = 0; k + j <= n; k + = I) {c2 [j + k] + = c1 [j] ;}} for (int j = 0; j <= (n); j ++) {c1 [j] = c2 [j]; c2 [j] = 0 ;}} printf ("% d \ n", c1 [n]);} return 0 ;}