HDU 動態規劃 K

來源:互聯網
上載者:User

標籤:

Problem KTime Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 44   Accepted Submission(s) : 19

 

題目描述:

有一隻經過訓練的蜜蜂只能爬向右側相鄰的蜂房,不能反向爬行。請編程計算蜜蜂從蜂房a爬到蜂房b的可能路線數。 其中,蜂房的結構如下所示。

Input輸入資料的第一行是一個整數N,表示測試執行個體的個數,然後是N 行資料,每行包含兩個整數a和b(0<a<b<50)。Output對於每個測試執行個體,請輸出蜜蜂從蜂房a爬到蜂房b的可能路線數,每個執行個體的輸出佔一行。Sample Input 2 1 2 3 6 Sample Output 1 3斐波那契額數列差不多::
#include<iostream>#include<cstring>using namespace std;__int64 dp[100];int main(){    int t;    cin >> t;    while(t--)    {        memset(dp, 0, sizeof(dp));        dp[0] = 1;        dp[1] = 1;        for(int i = 2; i < 60; i++)        {           dp[i] = dp[i - 1] + dp[i - 2];        }        int a, b;        cin >> a >> b;;        cout << dp[b - a] << endl;    }    return 0;}

 

HDU 動態規劃 K

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.