求M个桶放N个球,要求每个桶不空,用了隔板法,得不到正确结果。求高手
#include<stdio.h>#include<stdlib.h>
int main()
{
int M,N,num,n,m,a,b,t;
m=1,n=1,a=1,b=1,t=N-1;
while(scanf("%d%d",&M,&N)!=EOF){
while(m<=(M-1)){
a=a*m;
m++;
}
while(n<=(M-1)){
b=b*t;
t--;
n++;
}
num=b/a;
printf("%d",num);
printf("\n");}
system("PAUSE");
return 0;
}