Блог пользователя cauchyk

Автор cauchyk, 13 лет назад, По-английски
Can nCr % x (n choose r modulo any value)
computed by matrix exponentiation? if yes, how?
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

13 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

i think you need fast method to calculate binomial coefficients for large n and k.

if n and k is less than 10^6, or mudule less than 10^6, you can precalc all factoials up to 10^6.

You can calculate Cnk in such a way for not prime modules too. 

13 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится
i think you need fast method to calculate binomial coefficients for large n and k.

if n and k is less than 10^6, or mudule less than 10^6, you can precalc all factoials up to 10^6.

You can calculate Cnk in such a way for not prime modules too.
  • 12 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    "You can calculate Cnk in such a way for not prime modules too." how can i calc it for not primes modules, since i am using euclids algorithm i cant get it right for not prime modules.

13 лет назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

If N is very large (10^100 for example), and R is reasonably small (100 for instance), you can create (R+1)x(R+1) matrix A, which has ones on the main diagonal and on the diagonal above main, than compute v(A^N), where v is [1,0,0,0,...,0]. Last element of resulting vector will be the answer.

I believe this is what you were looking for

 

»
12 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can you/someone here please provide a problem link that needs this technique so that I can try my solution on that?

Thanks in advance :-)