Algorithm training The trouble time limit of the unnamed lake: 1.0s memory limit: 256.0MB problem description every winter, the North Lake is a good place to Skate. Peking University sports team prepared a lot of skates, but too many people, every afternoon after the day, often a pair of skates are not left.
Every morning, rental shoes window will be lined up long, fake with shoes of m, there is need to rent shoes N. The question now is how many of these people have a way to avoid embarrassing situations where the sports Group has no skates to Rent. (two people who have the same needs (such as rent shoes or shoes) exchange position is the same row METHOD) the input format is two integers, representing the M and n output formats an integer representing the number of schemes for the Queue. Sample Input 3 2 sample output 5 data size and convention m,n∈[0,18] sample Code:
1 Importjava.io.BufferedReader;2 Importjava.io.IOException;3 Importjava.io.InputStreamReader;4 5 public classMain {6 public Static voidMain (string[] Args)throwsnumberformatexception, IOException {7BufferedReader br =NewBufferedReader (NewInputStreamReader (system.in));8string[] str = br.readline (). split ("");9 Longm = Long.parselong (str[0]);Ten Longn = Long.parselong (str[1]); one a LongAns =program (m,n); - - System.out.println (ans); the - } - - /** + * Troop Arrangement - * @paramm also shoes number + * @paramn number of shoes to be rented a * @returnnumber of troop-arranging schemes at */ - public Static LongProgramLongMLongN) { - if(m<n)//If the number of shoes is less than the number of shoes, there will be no shoe rental situation - return0; - Else if(n==0)//If there is no one to rent shoes, there is only one situation, that is, the person who also shoes - return1; in Else - returnProgram (m-1, N) + program (m, n-1);//first person to also shoes + first person to rent shoes to } + -}
Blue Bridge Cup algorithm training ALGO-122 The trouble of the lake without name