1 exf[0]:=1; exf[1]:=1; 2 for i:=2 to n do exf[i]:=exf[mo mod i]*(mo-mo div i) mod mo; 3 for i:=1 to n do exf[i]:=exf[i-1]*exf[i] mod mo; //求n!的逆元
设p=kx+r,k=p div x,r=p mod x
p*x^-1*r^-1=k*r^-1+x^-1
0=k*r^-1+x^-1( mod p)
x^-1=-k*r^-1
x^-1=(p-p div x)*r^-1