poj 1664:放蘋果

#include<iostream>
using namespace std;
int count(int x,int y)
{
	if(x==1||y==1)
		return 1;
	else if(x>y)
		return count(x-y,y)+count(x,y-1);
	else if(y>x)
		return count(x,x);
	else if(x==y)
		return 1+count(x,y-1);	
}
int main()
{
	int m,n;//m蘋果數,n盤子數 
	int i;
	int t;
	cin>>t;
	for(i=0;i<t;i++)
	{cin>>m>>n;
	cout<<count(m,n)<<endl;}
	cin.get();
	return 0;
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章