poj 1664放苹果(转载,不详细,勿点)(递归)

题目和别人的解析传送门

我的代码

#include<bits/stdc++.h>
using namespace std;
int f(int m,int n)
{
    if(n==0) return 0;
    if(m==0||m==1) return 1;
    if(m>=n)
        return f(m-n,n)+f(m,n-1);
    else
        return f(m,m); 
}
int main()
{
    std::ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--)
    {
        int m,n;
        cin>>m>>n;
        cout<<f(m,n)<<endl;
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/zyacmer/p/10080049.html