tj
2025-08-13 09:53:51
发布于:四川
13阅读
0回复
0点赞
//放苹果 -- A7987
#include<bits/stdc++.h>
using namespace std;
int t;//测试数据数量
int m,n;//m个苹果 n个盘子
//构建函数
int f(int x,int y){
if(x==0 || y==1 || y==0) return 1;//边界
if(x<y){//苹果少于盘子
return f(x,x);
}
else{//苹果多余盘子
return f(x-y,y)+f(x,y-1);
}
}
int main(){
cin>>t;
for(int i=1;i<=t;i++){
cin>>m>>n;
cout<<f(m,n)<<endl;
}
return 0;
}
全部评论 1
6
2025-08-13 来自 四川
0










有帮助,赞一个