摘要: 二次剩余算法 解决的问题: 形如:求是否存在x满足 : x^2 = n (mod p) https://www.luogu.com.cn/problem/P5491 模板: ll n,p; ll w; struct num{ //负数 ll x,y; }; num mul(num a,num b,l 阅读全文
posted @ 2021-05-04 17:09 LaiYiC 阅读(52) 评论(0) 推荐(0)
摘要: BSGS算法 求关于x的方程a^x = b(mod p),gcd(a,p) = 0下的x; 算法流程: 令x = am -b y^(am-b) = z(mod p) yam = zyb (mod p) 枚举b = [0,m-1],map记录右边的值,枚举左边的a= [1,m+1] 每次查询右边map 阅读全文
posted @ 2021-05-04 12:07 LaiYiC 阅读(53) 评论(0) 推荐(0)