Problem Link: Combinations

This problem has a important part!You need to terminate every output with fullstop!otherwise you’ll get WA,i got 6times!

**Source Code:**

#include<stdio.h>

int main()

{

double n,r,ncr,g=1,h=1,k=1,x,sub;

while(scanf(“%lf %lf”,&n,&r)==2 &&n &&r)

{double i;x=0;g=1;h=1;k=1;h=1;sub=0;

for(i=2;i<=n;i++)

g*=i;

for(i=2;i<=r;i++)

h*=i;

sub=n-r;

for(i=2;i<=sub;i++)

k*=i;

x=g/(h*k);

printf(“%.0lf things taken %.0lf at a time is %.0lf exactly.\n”,n,r,x);

}

return 0;

}

Advertisements