蜜蜂路线

5、蜜蜂路线
【问题描述】
        一只蜜蜂在下图所示的数字蜂房上爬动,已知它只能从标号小的蜂房爬到标号大的相邻蜂房,现在问你:蜜蜂从蜂房M开始爬到蜂房N,M<N,有多少种爬行路线?
 
【输入格式】
 输入M,N的值。
【输出格式】
 爬行有多少种路线。
【输入样例】bee.in
   1  14
【输出样例】bee.out
   377
 
//include<AC自动机>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
int b[10001];
using namespace std;
int main()
{
    int n;
    int m;
    cin>>m>>n;int l=n-m;
    b[1]=1;
    b[2]=1;
    for(int i=3;i<=l+1;i++)
    {
        b[i]=b[i-1]+b[i-2];
    }
    cout<<b[l+1];
    return 0;
}
原文地址:https://www.cnblogs.com/sssy/p/6598962.html