There is N balls in a box, you can take one can take one, ask: To take the ball inside the box, how many kinds of medicines! 1, (I my own algorithm, more complicated) Direct INT n = N / 2 directly through the arrangement combination; int total = c (0, n) c (1, (N-1)) ... c (N, (NN)); C (A, B) = B! / [A! (Ba)!] Verification: n = 2: n = 2/2 = 1; Total = C (0, 2) C ( 1, 1) = 1 1 = 2; n = 3; n = 3/2 = 1; Total = C (0, 3) C (1, 2) = 1 2 = 3; n = 4; N = 4/2 = 2; Total = C (0, 4) C (1, 3) C (2, 2) = 1 3 1 = 5; ***** / * * CREATED ON 2004- 11-19 * * Todo to change the Template for this generated file go to * window - preferences - java - code style - code templates * /
/ ** * @Author administrator * * Todo to change the template for this generated type comment Go to window - * preferences - java - code style - code templates * / public class total {
/ ** * * / public total () {super (); // Todo auto-generated constructor stub}
Public static void main (string [] args) {int n = integer.parseint (args [0]); Total T = New Total (); system.out.println ("can have" t.count (n) "Method");
Public int count (int N) {int sum = 0; int N = N / 2; for (int i = 0; i <= n; i ) {SUM = SUM COUNT (i, (n - i)); } Return Sum;}
Public int count (int A, int b) {
RETURN (Step (b) / (Step (a) * (Step (b - a))));
Public int adjust = 1; for (int i = 1; i <= n; i ) {result = result * i;} return fruit;}} 2, looking at other people's algorithms, indeed Different to the Different Methods, Different Methods, P (X) = P (x> 2) P (x> 2) (x> 2) Boundary conditions: p (1) = 1, p (2) = 2 This seems to be fibonacci numbers