【ACM】POJ 1664

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/CSDN___CSDN/article/details/83867362

现在还不能理解为什么

至少有一个盘子用f(m,n-1)表示就可以了 

AC:

#include <iostream>
#include <cstdio>
using namespace std;
int f(int m,int n)
{
	if(m==1 || n==1 || m==0)	return 1;
	else if(m<n)	return 	f(m,m);
	else
	{
		return f(m-n,n)+f(m,n-1);
	}
}
int main ()
{
	int m,n,T;
	cin>>T;
	while(T--)
	{
		cin>>m>>n;
		printf("%d\n",f(m,n));
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/CSDN___CSDN/article/details/83867362