View Code of Problem 787

#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stdio.h>
#include<string.h>
#include<cmath>
using namespace std;
int n,m,maxx=0;
int dfs(int x,int y)
{
    if(y==1||x==0)
        return 1;
    if(x<y)
        return dfs(x,x);
    else return dfs(x,y-1)+dfs(x-y,y);
}
int main()
{
    int times;
    cin>>times;
    while(times--)
    {
        maxx=0;
        cin>>n>>m;
        cout<<dfs(n,m)<<endl;
    }
   return 0;
}

Double click to view unformatted code.


Back to problem 787