unseen2's blog

By unseen2, 6 months ago, In English

I was trying to solve the following problem:- you are given 10 groups containing k items, each item is indexed with group number 0 to 9; find the number of ways of selecting n items out of given groups. give answer in mod(10^9 +7)
n<= 10^9; 10*N<= k.
i was utilizing Begger's method of selection. but it was getting WA in some cases and i wasn't able to figure out why;
f(x) = (x^0 + x^1 + x^2 + x^3 ......+ x^k) represents selection of item from one group(coefficient of x^t represents ways of selecting t items from 1 group) for 10 groups it would be
g(x) = f(x)^10
now from g(x) I need to select the coefficient of x^n; so I used binomial expansions of each series and tried the following logic.

for( i = 0; i<=10 ; i++)
{ 
  for( j = 0; j <= 10 ; j++)
  {
    if( i + j*(k+1) == n)
{
   val = ncr(10 + i -1 , i)* ncr(10 , j);
if( j%2) val*=-1;
ans += val;
}
}


please can anyone give their insights on the above quetion and if there is any other efficient method to solve such problem. related problems would be much appreciated. Thanks in advance (:

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it