HDU Dynamic Programming K

Source: Internet
Author: User

Problem Ktime limit:2000/1000ms (java/other) Memory limit:65536/32768k (Java/other) total submission (s): + Accept Ed Submission (s): 19

Title 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.

Inputthe first line of the 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). Outputfor each test instance, output the number of possible routes that bees crawl from hive A to hive B, with the output of each instance one row. Sample Input21 23 6 Sample Output13The Fibonacci amounts are similar::
#include <iostream>#include<cstring>using namespaceStd;__int64 dp[ -];intMain () {intT; CIN>>T;  while(t--) {memset (DP,0,sizeof(DP)); dp[0] =1; dp[1] =1;  for(inti =2; I < -; i++) {Dp[i]= Dp[i-1] + dp[i-2]; }        intA, B; CIN>> a >>b;; cout<< Dp[b-a] <<Endl; }    return 0;}

HDU Dynamic Programming K

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.