Question:
Solution:
double nCr(int n,int m){
int k;
register int i,j;
double c,d;
c=d=1;
k=(m>(n-m))?m:(n-m);
for(j=1,i=k+1;(i<=n);i++,j++){
c*=i;
d*=j;
if( !fmod(c,d) && (d!=1) ){
c/=d;
d=1;
}
}
return c;
}
int k;
register int i,j;
double c,d;
c=d=1;
k=(m>(n-m))?m:(n-m);
for(j=1,i=k+1;(i<=n);i++,j++){
c*=i;
d*=j;
if( !fmod(c,d) && (d!=1) ){
c/=d;
d=1;
}
}
return c;
}
int main(){
....
....
....
}
No comments:
Post a Comment