1. 程式人生 > >poj 1664放蘋果(轉載,不詳細,勿點)(遞迴)

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; }