hdu2044(组合数学)

题意:


 
蜜蜂在蜂巢里爬,只能向右爬,不能回头,问从a到b有几种路线;

易得way[i] = way[i - 1] + way[i - 2];

将way[a]和way[b]赋值1,然后递推;


#include
#include

long long way[55];
int main() {
	int t;
	scanf("%d",&t);
	int a,b;
	while(t--) {
		scanf("%d%d",&a,&b);
		way[a] = 1;
		way[a + 1] = 1;
		for(int i = a + 2; i <= b; i++)
			way[i] = way[i - 1] + way[i - 2];
		printf("%lld\n", way[b]);
	}
	return 0;
}


你可能感兴趣的:(组合数学)