4
2
2013
3

Lucas定理——求组合数取模

考虑n! mod p

n! mod p

 = (1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * ... n) mod p

 = (1 * 2 * 3 * ... * p * p+1 * p+2 * ... * 2p * 2p+1 * 2p+2 * 2p+3 * ...) mod p

 = (1 * 2 * 3 * ... * p-1 * p+1 * p+2 * ... * 2p-1 * 2p+1 * ... *p^(n/p-1)* (2*3*...*n/p) ) mod p

其中

1 * 2 * 3 * ... p-1 mod p = p+1 * p+2 * p+3 * p+4 ... * 2p-1 mod p = ... = (n%p!) mod p

相当于每p段加上p,所以全部约掉,就是n%p! mod p。

所以,只需要计算C(n%p,m%p) * Lucas(n/p,m/p)

简化: 

C(N,M) mod p=C(Np0,Mp0)*C(Np1,Mp1) * C(Npx,Mpx)

NpX,MpX表示N和M在p进制下的第 X 位。

----------------------------------------------------------------------------------------------------------------------------------------

扩展,求C(N,M) MOD P^c

……前面变成p^c周期……然后单独处理周期。。
Category: OI | Tags: 数学 | Read Count: 1165
babysitting services 说:
2019年9月11日 00:25

HomeMaids Washing Services offers many Warehouses, Universities, Hospitals, Retailers, Showrooms & Professional Cleaning, this is from a tiny office around large manufacturing facility units. Our almost all staff are usually fully trained for your job which they undertake whether it's buffing surfaces, using scrubber driers or perhaps general cleaning at the office.

maid services dubai 说:
2021年9月18日 23:08

Rugs and carpeting, undoubtedly, are one of the many hotbeds from germs like they are looking at continuous allergens and airborne dirt and dust. And, some dirty rugs can invest significantly towards indoor carbon dioxide. So, cleaning them more frequently, especially previously winter can benefit you in a few ways.

maid agency dubai 说:
2022年3月27日 21:41

While acknowledging that, it is way better to join up and activate a tidier service in regards to maintaining the home clean, continually. The tidier service can provide house cleaning up service with high benchmarks guaranteeing you actually always come to the house to your clean plus healthy ecosystem. As already mentioned, it is often better to hunt aid with house tidier service this benefits you and your folks. A professional home cleaning company is often contacted to be able to have your dirt-free plus hygienic dwelling.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com