Blue Bridge Cup Java algorithm training The troubles of the lake without name

Source: Internet
Author: User
Description of the problem 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] Recursive
Import Java.util.scanner;public class Main {public static int fun (int m, int n) {if (n = = 0) {return 1;} else if (M < n) {return 0;} else {return fun (m-1, N) + fun (m, n-1);//recursive}}public static void Main (string[] args) { Scanner sc = new Scanner (system.in); int m = Sc.nextint (); int n = sc.nextint (); Sc.close (); System.out.println (Fun (M, n));}}

  

Blue Bridge Cup Java algorithm training The troubles of the lake without name

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.