- 博客(4)
- 收藏
- 关注
转载 BSGS算法!
求解关于x的方程a^x=z(modp),其中gcd(a,p)=1.做法的话并不难,但是要搞懂细节还蛮多的。bsgs算法是这样的:x可以写成i*m-j的形式(这里m取值随意,但是取√p上取整时跑的最快) a^(im-j)≡z(mod p) 推得 a^im≡z*(a^j)那么我们枚举j的值从1--m,将算出的z*(a^j)加入map里面再枚举...
2019-07-24 07:28:00
149
转载 excrt(拓展中国剩余定理)
对于一个同余方程对于第一个和第二个式子则有:ans=a1+k1∗n1ans=a2+k2∗n2就有:a1+k1∗n1=a2+k2∗n2k1∗n1−k2∗n2=a2−a1故我们设c=a2−a1再变化一下形式就有:k1∗n1+(−k2)∗n2=c令gcd=gcd(n1,n2)这样我们就可以通过e...
2019-07-23 11:58:00
110
转载 卡特兰数
这里整合一下正确无误的卡特兰数公式1.递推式1:f(n)=sigma(f[i]*f[n-1-i]) (0<=i<=n-1)2.递推式2:f(n+1)=f(n)*(4n+2)/(n+2);注:递推式中f(0)=1;3.通项公式1:f(n)=C(2n,n)/(n+1)=(2n)!/[(n!)*(n+1)!];4.通项公式2:f(n)=C(2n,...
2019-07-21 15:07:00
184
转载 POJ 3013 Big Christmas Tree
Big Christmas TreeInputThe input consists ofTtest cases. The number of test casesTis given in the first line of the input file. Each test case consists of several lines. Two numbe...
2019-03-06 16:49:00
102
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人