| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
用正整数的无序分拆即可In Reply To:Re:求助 Posted by:lily at 2005-09-02 22:04:39 程序如下:
#include<iostream>
using namespace std;
int B(int,int);
int main()
{
int t,m,n;
cin>>t;
for(int i=0;i<t;++i)
{
cin>>m>>n;
int sum=0;
for(int j=1;j<=n;++j)
sum+=B(m,j);
cout<<sum<<'\n';
}
}
int B(int n,int k)
{
if(k==1||n==k) return 1;
else
{
if(k>n) return 0;
else
{
int result=0;
for(int l=k;l>0;--l)
result+=B(n-k,l);
return result;
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator