PKU1664

递推。考虑最小的一个

f(m,n)=f(m,n-1)+f(m-n,n);

所有的方案=最少的一个盘子没有,m个全在其他N-1个中 + 最少盘子里至少有一个,即每个盘子里都至少有一个

  • Source Code
    #include<iostream>
    using namespace std;
    int t,n,m;
    int f(int a,int b)
    {
     if(a<0) return 0;
     if(a==0 || b==1 ||a==1) return 1;
     return f(a,b-1)+f(a-b,b);
     }
    int main()
    {
     cin>>t;
     while(t--)
     {
      cin>>m>>n;
      cout<<f(m,n)<<endl;
      }
     return 0;
     }
  • 阅读全文
    类别: 默认分类  查看评论

    你可能感兴趣的:(PKU1664)