zoukankan      html  css  js  c++  java
  • HDU-2044-一只小蜜蜂

    链接:https://vjudge.net/problem/HDU-2044

    题意:

    有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行。请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数。 
    其中,蜂房的结构如下所示。 
     

    思路:

    刚开始按位置递推,后来发现是按照距离递推。

    代码:

    #include <iostream>
    #include <memory.h>
    #include <vector>
    #include <map>
    #include <algorithm>
    #include <cstdio>
    #include <math.h>
    #include <queue>
    #include <string>
    #include <stack>
    #include <iterator>
    
    using namespace std;
    
    typedef long long LL;
    
    const int MAXN = 60;
    
    LL a[MAXN];
    
    int main()
    {
        a[1] = 1;
        a[2] = 2;
        for (int i = 3;i <= 50;i++)
            a[i] = a[i - 1] + a[i - 2];
        int t;
        cin >> t;
        while (t--)
        {
            int l, r;
            cin >> l >> r;
            cout << a[r - l] << endl;
        }
    
        return 0;
    }
    

      

  • 相关阅读:
    Test
    占位2
    开坑纪念
    function 类型(函数定义)----读书总结
    css位元素 after
    算法-哈希表
    CF547D
    CF538H
    CF516D
    CF505E
  • 原文地址:https://www.cnblogs.com/YDDDD/p/10639956.html
Copyright © 2011-2022 走看看