![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
BSGS
DZYO
Never stop
展开
-
poj3243:Clever Y(BSGS)
传送门题意: 求Ax≡B(modC)A^x\equiv B\pmod {C}的最小X解。题解: BSGS 。模板:#include<iostream> #include<cmath> #include<algorithm> #include<cstring> #include<cstdio> using namespace std; namespace IO { streambuf *i原创 2017-09-13 09:53:58 · 267 阅读 · 0 评论 -
BZOJ5104:Fib数列(二次剩余+BSGS)
传送门 题意: 给定aa,求Fn≡a(mod1e9+9)F_n \equiv a \pmod{1e9+9},输出最小的nn。 题解: Fib数列的通项:Fn=15√((1+5√2)x−1−5√2)n)F_n=\frac{1}{\sqrt{5}}((\frac{1+\sqrt{5}}{2})^x-\frac{1-\sqrt{5}}{2})^n)。 55是1e9+91e9+9的一类二次剩余。原创 2017-12-29 20:41:23 · 1321 阅读 · 0 评论 -
Codechef:Luckydays(BSGS)
传送门 题解: md这鬼畜的时限让我卡了半天常,以后hash不能偷懒写vector了。。 对于这道题,我们构造转移矩阵: ⎛⎝⎜⎜0x01y0011⎞⎠⎟⎟(010xy1001) \begin{pmatrix} 0 & 1 &0\\ x & y & 1 \\ 0 & 0 & 1 \end{pmatrix} 显然这个矩阵的行列式为−y−y-y,首先特判掉y=0y=0y=0的情况,之后这...原创 2018-03-02 14:44:04 · 269 阅读 · 1 评论