摘要: #include #include #include #include #define N 250 #define M 250 #define INF 100000000 using namespace std; int head[N],cur[N],lev[N],ecnt=1,S,T,n,m; queue q; struct adj { int nxt,v,w; }e[2*M]; v... 阅读全文
posted @ 2017-11-29 20:07 MSPqwq 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 1 namespace Hash 2 { 3 const ll N=50000; 4 const ll H=999979; 5 struct adj 6 { 7 ll nxt,v,num,val; 8 }e[N]; 9 ll head[H],ecnt=0; 10 void init() 11 { 12 ... 阅读全文
posted @ 2017-11-29 17:49 MSPqwq 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 题目: 给你A,B,K 求最小的x满足Ax=B (mod K) 题解: 如果A,C互质请参考上一篇博客 将 Ax≡B(mod C) 看作是Ax+Cy=B方便叙述与处理. 我们将方程一直除去A,C的最大公约数进行变形,最终使得A和C互质. 将方程同除d1=gcd(A,C),得到B1=A/d1*Ax-1 阅读全文
posted @ 2017-11-29 17:25 MSPqwq 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 题目: 给出A,B,C 求最小的x使得Ax=B (mod C) 题解: bsgs算法的模板题 bsgs 全称:Baby-step giant-step 把这种问题的规模降低到了sqrt(n)级别 首先B的种类数不超过C种,结合鸽巢原理,所以Ax具有的周期性显然不超过C 所以一般的枚举算法可以O(C) 阅读全文
posted @ 2017-11-29 15:57 MSPqwq 阅读(181) 评论(0) 推荐(0) 编辑