Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:请问:怎么递归啊?

Posted by lilove at 2008-12-31 15:38:59 on Problem 1664
In Reply To:Re:请问:怎么递归啊? Posted by:ZSUKINGDOM at 2004-06-05 00:25:05
> #include <iostream.h>
> int total=0;
> int a[11]={0};
> void work(int m,int n,int dep)
> {
>    int i,v;
>    if (dep==n) total++;
>    else
>    {
>    v=n-dep+1;
>    for (i=a[dep-1];i<=m/v;i++)
>      {
>      a[dep]=i;
>      work(m-i,n,dep+1);
>      }
>    }
> }
> int main()
> {
>  int t,m,n;
>  cin>>t;
>  while (t>0)
>   {
>     a[0]=1;
>     cin>>m>>n;
>     while (n>0)
>     {
>     work(m,n,1);
>     n--;
>     }
>     cout<<total<<endl;
>     total=0;
>     t--;
>   }
>  return  0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator