Blue Bridge Cup algorithm training ALGO-150 6-1 recursive two-item coefficient value

Source: Internet
Author: User

Algorithm training 6-1 Recursive two-term coefficient value time limit: 10.0s memory Limit: 256.0MB problem Description Sample Enter an input example that satisfies the requirements of the topic.
3 10 Sample output corresponds to the output of the sample input above.
Data size and convention the range of each number in the input data.
Example: The result does not overflow when int is represented. Topic Analysis: for recursive problems, we pay attention to two points: (1) Find the exit; (2) Find similarity. in the subject we know: (1) The export has been found: when k = 0 or k = n, the result is 1. (2) similarity has also been found: when 0 < K < N, recursive call

Example code:

1 ImportJava.io.BufferedReader;2 Importjava.io.IOException;3 ImportJava.io.InputStreamReader;4 5  Public classMain {6      Public Static voidMain (string[] args)throwsioexception{7BufferedReader br =NewBufferedReader (NewInputStreamReader (system.in));8string[] str = Br.readline (). Split ("");9         intm = Integer.parseint (str[0]);Ten         intn = integer.parseint (str[1]); One          A         intcoefficient =Binomialcoe (m,n); -          - System.out.println (coefficient); the     } -  -     Private Static intBinomialcoe (intKintN) { -         if(k = = 0 | | k = =N) +             return1; -         returnBinomialcoe (k, n-1) + Binomialcoe (k-1, n-1); +     } A}

Blue Bridge Cup algorithm training ALGO-150 6-1 recursive two-item coefficient value

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.