加载中...

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 17 下一页
摘要: 因为乘是o1 但a56爆大奖在线娱乐们变成olog //龟速乘 将乘法变成加法 a*b%k LL qmul(LL a, LL b, LL c) { LL res = 0;// 加法的0元为0 while (b) { if (b & 1) res = (res + a) % c; a = (a + a) % c; b 阅读全文
posted @ 2022-08-08 23:10 liang302 阅读(16) 评论(0) 推荐(0) 编辑
摘要: x和y的最大公约数是d (x,y)=d 转化成方程 ax+by=d 参数x和y相关的表达式 x y正负不管 x=x0+kb/d (对方的那坨来加的) y=y0-ka/d //拓展欧几里得 int exgcd(int a, int b, int &x, int &y)//ax=d%(mod b) x和 阅读全文
posted @ 2022-08-08 21:10 liang302 阅读(129) 评论(0) 推荐(0) 编辑
摘要: φ(N)=N(1-1/p1)(1-1/p2)(1-1/p3)(1-1/p4)…..(1-1/pn) //注意这里的n φ(1)=1 1.欧拉函数是积性函数——若 m,n 互质,φ(mn)=φ(m)φ(n) 2.若 n 是素数 p 的 k 次幂,φ(n)=p^k-p^(k-1)=(p-1)p^(k-1 阅读全文
posted @ 2022-08-07 01:54 liang302 阅读(483) 评论(0) 推荐(0) 编辑
摘要: ##越狱 https://www.acwing.com/problem/content/1292/ n个房间m个宗教 求2个相同相邻宗教的情况 : 正难则反 ! m^n-m*(m-1)^(n-1) //所有情况-a56爆大奖在线娱乐房间信奉不同宗教的情况(第一个房间是m 第二情况必须不同a56爆大奖在线娱乐是m-1) cout < 阅读全文
posted @ 2022-08-06 23:50 liang302 阅读(28) 评论(0) 推荐(0) 编辑
摘要: N=(p1^c1)(p2^c2)...(pk^ck) N^2=(p1^(c1**2)) * (p2^ (c22) )...(pk^ (ck*2) ) ##约数个数 f[N]=(c1+1)(c2+1)...(cn+1) ##拍打牛头https://www.acwing.com/problem/cont 阅读全文
posted @ 2022-08-06 23:47 liang302 阅读(41) 评论(0) 推荐(0) 编辑
摘要: ##相邻质数距离 https://www.acwing.com/problem/content/198/ #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef long lon 阅读全文
posted @ 2022-08-06 18:06 liang302 阅读(30) 评论(0) 推荐(0) 编辑
摘要: #三种祖先关系 a是b祖先 b是a祖先 a和b不是祖先关系 #树上多个点的LCA,就是DFS序最小的和DFS序最大的这两个点的LCA 必备:知道根节点 必须存下来 有可能跳过根节点 int depth[N],f[][N];//N为(log节点数)+1 int q[N]; 从根节点开始预处理; 需要设 阅读全文
posted @ 2022-07-25 14:49 liang302 阅读(47) 评论(0) 推荐(0) 编辑
摘要: ##https://ac.nowcoder.com/acm/contest/33187/K 给出子串和母串长度 求母串的可能性 #include <iostream> #include <cstring> using namespace std; using i64 = long long; con 阅读全文
posted @ 2022-07-23 18:40 liang302 阅读(20) 评论(0) 推荐(0) 编辑
摘要: ##大盗阿福https://www.acwing.com/problem/content/1051/ f[i][0]a56爆大奖在线娱乐不偷第i家的最大费用 两个状态 偷这家+不偷这家+ #include <iostream> #include <cstring> #include <algorithm> usin 阅读全文
posted @ 2022-07-23 17:32 liang302 阅读(11) 评论(0) 推荐(0) 编辑
摘要: ##兴奋值 https://ac.nowcoder.com/acm/contest/37160/H #include <algorithm> #include <iostream> #include <cstring> #include <cstdio> #include <cmath> using 阅读全文
posted @ 2022-07-21 18:32 liang302 阅读(33) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 17 下一页