This way 题意: 告诉你B,N,P,让你求最小的L使得 题解: BSGS模板,大致意思是将L变成ax+b的形式,定下x之后,式子就变成了这样: B b = = N B − a x ( m o d P ) B^b==NB^{-ax}(mod P) Bb==NB−ax(modP) 那么我们只需要先枚举b(0<=b<=x),将所有值都记下来,再枚举a,同时查询即可。 这道题如果将x
BSGS算法,预处理出 ϕ(c)−−−−√ \sqrt{\phi(c)}内的a的幂,每次再一块一块的往上找,转移时将b乘上逆元,哈希表里O(1)查询即可 #include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<cmath>#include<map>#define LL long lo