国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

HDU-2044-一只小蜜蜂...(簡單DP)

2019-11-06 06:48:32
字體:
來源:轉載
供稿:網友
//傳送門:http://poj.org/PRoblem?id=3979#include <queue>#include <functional>#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <stack>#include <vector>#include <set>#include <map>#include <string>#include <cmath>#include <cstdlib>#include <ctime>#include <assert.h>using namespace std;#define N 55long long  dp[N];       //注意可能超 int,并且進行打表int main(){ int t; scanf("%d",&t); while(t--){   int a,b;   scanf("%d%d",&a,&b);   if(a>b){             // a>b 輸出0      printf("0/n");      continue;   }   memset(dp,-1,sizeof(dp));// 如果沒查詢過,則為-1   dp[0]=dp[1]=1;           // 斐波那契數列 第0位 與 第1位 為1   if(dp[b-a]!=-1){         // dp[b-a] 值不為 -1,則表示已經查詢過,直接輸出結果   printf("%lld/n",dp[b-a]);   continue;   }else{   for(int i=2;i<=b-a;i++){     dp[i]=dp[i-1]+dp[i-2];  // 由于蜜蜂只能往右走,則可能從第 i-2 與 第 i-1位 到第 i 位   }   }   printf("%lld/n",dp[b-a]); } return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 彭阳县| 满城县| 中方县| 焦作市| 屏山县| 凤城市| 宣城市| 昭通市| 万荣县| 育儿| 新干县| 兴业县| 溆浦县| 博爱县| 呼伦贝尔市| 鄯善县| 上高县| 乳源| 马山县| 清徐县| 来宾市| 银川市| 郓城县| 比如县| 靖安县| 连云港市| 布拖县| 宿州市| 忻城县| 将乐县| 偏关县| 陇川县| 虞城县| 龙游县| 竹北市| 汨罗市| 南木林县| 阿克陶县| 阿荣旗| 逊克县| 菏泽市|