标签:
Description
Input
Output
Sample Input
2 1 2 3 6
Sample Output
1 3
题解:因为蜂房的特殊结构,1到n的步数和k+1到n+k的步数是相等的
所以用dp[n-1]来储存步数。
dp[i] = dp[i-1] + dp[i-2];(i大于2);
#include<cstdio> #include<cstring> #include<iostream> #include<stdlib.h> #include<vector> #include<queue> #include<cmath> using namespace std; #define maxn 100 #define oo 0x3f3f3f #define PI 3.1415926535897932 int n; int k; long long dp[maxn]; void init() { for(int i=3; i<=maxn; i++) dp[i] = dp[i-1] + dp[i-2]; } int main() { int t; scanf("%d", &t); dp[1] = 1; dp[2] = 2; while(t--) { init(); int m,n; scanf("%d%d",&m,&n); k = n - m; printf("%I64d\n",dp[k]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/biu-biu-biu-/p/5744488.html