Computer Science, asked by skingdwivediosofv6, 1 year ago

Tom the cat is brushing up his Math skills. He has a bag containing N balls of different colors. Now Tom can randomly pick any even number of balls from the bag. Tom wants to find out the sum of all such combinations of balls that he can pull out from the bag. Given he can pull out at max K balls in one pick.

Input Format:

First line contains two space separated numbers N and K

Answers

Answered by Anonymous
10
#include
unsigned long long int fact(unsigned long long int);
int main()
{
unsigned long long int k,s=0,i,n;
scanf("%llu %llu",&n,&k);
if(n>0 && n>=k && k<=100000000000000)
{
for(i=0;i<=k;i+=2)
{
s+=(fact(n)/(fact(i)*fact(n-i)));
printf("%llu\n",s);
}
s = s % 1000000007;
printf("%llu",s);
}
return 0;
}
unsigned long long int fact(unsigned long long int n)
{
if(n==1)
return 1;
else if(n==0) return 1;
else
return(n*fact(n-1));
}
Similar questions