View Code of Problem 787

#include<iostream>

using namespace std;

int fun(int m,int n){
       if(m<n) return fun(m,m);
     if(m==1||n==1) return 1;
       if(m==0) return 1;
     return fun(m,n-1)+fun(m-n,n);
}

int main(){
    int t,m,n;
    cin>>t;
    while(t--){
        cin>>m>>n;
        cout<<fun(m,n)<<endl;
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 787