Hdu 20,441 Little Bees ... (Java)

Source: Internet
Author: User

Problem:

The first use of int failed to change to a long on the line, each time do not know whether enough to measure a limit value


A little bee ...Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 46893 Accepted Submission (s): 17087


Problem description A trained bee can only crawl to the right side of the hive and cannot crawl backwards. Please program the number of possible routes that bees crawl from hive A to hive B.
Among them, the structure of the hive is shown below.


The first line of input data is an integer n, representing the number of test instances, followed by n rows of data, each containing two integers a and B (0<a<b<50).

Output for each test instance, print the number of possible routes that the bee crawls from hive A to hive B, with the output of each instance one row.

Sample Input
21 23 6

Sample Output
13

Code:

Import java.util.*;p ublic class main{public static void Main (string[] args) {Scanner cin=new Scanner (system.in); int n=cin . Nextint (); for (int i=0;i<n;i++) {int a=cin.nextint (); int b=cin.nextint (); Long s[]=new long[50];for (int j=a+2;j< 50;j++) {s[a]=1;s[a+1]=2;s[j]=s[j-1]+s[j-2];} System.out.println (S[b-1]);}}


Hdu 20,441 Little Bees ... (Java)

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.