Source: http://acm.nyist.net/JudgeOnline/problem.php? PID = 1, 571
This is a representative expression that integrates all types of integer division.
The division of N cannot exceed M. It can be written as recursion.
Define a function, void fun (INT num, int limit, int deep)
Num is the number to be divided.
The limit cannot exceed this limit.
Deep Is the depth, that is, dividing several numbers. For example, if we divide 5, the depth of the Division cannot exceed 5.
Int A [100]; // The Int B [5] array of the number of records; // used to record the results of each division. Int n, m; void fun (INT num, int limit, int deep) {If (num = 0) {B [0] ++; If (M = Deep) B [1] ++; int bigm = 0, jishu = 0, allno = 0; For (INT I = 0; I <deep; I ++) {if (a [I]> m) bigm = 1; if (a [I] % 2 = 0) jishu = 1; for (Int J = I + 1; j <deep; j ++) {if (I! = J & A [J] = A [I]) allno = 1 ;}} if (! Bigm) B [2] ++; If (! Jishu) B [3] ++; If (! Allno) B [4] ++; // cout <Endl;} else for (INT I = limit; I <= num; I ++) // I = Limit aims to increase the number of partitions in ascending order. {A [Deep] = I; // record the divided numbers fun (Num-I, I, deep + 1); // start recursion }}
Int main () {While (scanf ("% d", & N, & M )! = EOF) {for (INT I = 0; I <5; I ++) B [I] = 0; fun (n, 1, 0); For (INT I = 0; I <5; I ++) cout <B [I] <Endl; cout <Endl;} return 0 ;}
But it seems that I can't use the AC question. I don't know why .. Please kindly advise.