UVa 369

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

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s