Code: Select all
#include<stdio.h>
long long int combinFnc(short int n,short int m) {
long long int finalVal=1;
short int multList[51]={0},divList[51]={0};
register short int i,j,k=0;
for(i=(n-m)>m?(n-m+1):m+1,j=(n-m)>m?m:(n-m);(i<=n || j>=2);i++,j--,k++) {
if(i<=n)
multList[k]=i;
if(j>=2)
divList[k]=j;
}
/*beginDebug
for(i=0;divList[i]!=0;i++)
printf("*%hd*\n",divList[i]);
endDebug */
for(i=0;divList[i]!=0;i++) {
for(j=0;multList[j]!=0;j++) {
if((multList[j]%divList[i])==0){
multList[j]/=divList[i];
break;
}
}
}
for(i=0;multList[i]!=0;i++)
finalVal*=multList[i];
return finalVal;
}
int main() {
short int n,m;
while(1) {
scanf("%hd %hd",&n,&m);
if(n==0 && m==0)
break;
else
printf("%hd things taken %hd at a time is %lld exactly.",n,m,combinFnc(n,m));
}
return 0;
}
I get WA everytime with 0.008 second runtime.
Same thing happens in 530 (i tried that with different output formatting)
Somebody Please HELP.
![:oops:](./images/smilies/icon_redface.gif)
Thanks a lot