Hive issue

Hive problem : there is a trained bees can only be climbed right adjacent hive, not the reverse crawl. Calculation program a number of possible routes to climb bee hive from hive b a.
Wherein the honeycomb structure shown below.
Here Insert Picture Description
I intend to use at the start of the search method to search out the path and found very complex, and finally found the result was a series of similar Feibolaqi results.

#include<bits/stdc++.h>
#define check(x,y) (x<2&&x>=0&&y>=0&&y<30)
using namespace std;
int a[1000];
void solve(){
    a[0]=0;
    a[1]=1,a[2]=1;
    for(int i=3;i<1000;i++){
        a[i]=a[i-1]+a[i-2];
    }
}


int main()
{
        int n,m;
        solve();
        while(~scanf("%d %d",&n,&m)){
                printf("%d\n",a[m-n+1]);
        }
        return 0;
}

Published 17 original articles · won praise 1 · views 532

Guess you like

Origin blog.csdn.net/qq_43520913/article/details/104371995