time limit: 2000/1000 ms (java/others) memory limit: 65536/32768 k (java/others)
total submission(s): 11896 accepted submission(s): 8424
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
sample output
题意:把一个数因式分解,点到顺序的不算,比如5=1+4和5=4+1就算是一种方式
题解:等于在式子的‘+’号后面一次加上一个数字形成新的,而且要求加上的这个数字是当前式子里面最大的,这样就不会重复
如:(去想象这个表中的数据是一行一行从左向右刷出来的“一行的定义是每个+n算一行”,每次刷的位置的各种情况都是根据先前已经算出来了的数据得来的)
分解的那个整数 1
2 3
4 5 6
+1 1
1+1
1+1+1 1+1+1+1
1+1+1+1+1
1+1+1+1+1+1
————————————————————————————————————————
+2 2
1+2
1+1+2 1+1+1+2
1+1+1+1+2
2+2
1+2+2
1+1+2+2
2+2+2
+3 3
1+3
1+1+3
1+1+1+3
2+3
1+2+3
3+3
+4 4
1+4
1+1+4
2+4
+5 5
1+5
+6 6
因式分解的方式数:1
2 3 5
7 11
比如+1的时候,6就从5里面找,因为5+1=6,+2的时候6就从4里面找,+3的时候就从3里面找,这么算下去,到+6的时候,6本身也算进来,所以就等于从0里面加一个