上一页 1 2 3 4 5 6 7 8 9 10 ··· 28 下一页
摘要: 二维数组做函数参数时,第一维可以省略,第二位不可省略,必须为一个常数。 例如: const int N=1000; void mul(int a[][N],int b[][N]) { } View Code 阅读全文
posted @ 2022-09-12 20:31 80k 阅读(33) 评论(0) 推荐(0) 编辑
摘要: 主要思路为,在Floyd过程中,找到环中最大值为k的最小环 解释: 以dp的视角看待Floyd算法,在循环到k时,已经获得了经过前k-1个点的最短路径。 设环中最大标号为k,则路径可以表示为:i->k->j->...->i i->k和k->j为直接相连,j->...->i为通过小于标号k的点相连。 阅读全文
posted @ 2022-09-12 19:46 80k 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 问题:求和:1^k+2^k+...+n^k 例题: https://codeforces.com/contest/622/problem/F 代码: #include<bits/stdc++.h> #define fore(x,y,z) for(LL x=(y);x<=(z);x++) #defin 阅读全文
posted @ 2022-09-10 21:59 80k 阅读(151) 评论(0) 推荐(0) 编辑
摘要: exgcd用于计算,形如ax+by=c的解。 证明:参考:https://www.cnblogs.com/mrclr/p/9380300.html 1、利用exgcd求解ax0+by0=gcd(a,b)的一个解: LL ExGCD(LL a, LL b, LL &x, LL &y) { if (b 阅读全文
posted @ 2022-09-10 11:28 80k 阅读(20) 评论(0) 推荐(0) 编辑
摘要: https://atcoder.jp/contests/abc267/tasks/abc267_f 此题目首先有结论:距离树上任意一点距离最远的点,是直径的其中一个端点 https://www.cnblogs.com/ydUESTC/p/16664485.html 故对于一个查询u,k如果存在一个答 阅读全文
posted @ 2022-09-07 11:21 80k 阅读(48) 评论(0) 推荐(0) 编辑
摘要: 对于一棵树,定义点的距离为二者的最短路径长度,可以有 树的直径的端点为(L,R) 对于任意一点u,L或R为距离u最远的点。 证明: https://atcoder.jp/contests/abc267/editorial/4753 阅读全文
posted @ 2022-09-07 10:35 80k 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 踩坑记录: 对于max_element(begin,end); 如果begin==end,则当前查找的区间范围为0, 此时,会直接返回begin,导致答案(可能)错误。 阅读全文
posted @ 2022-09-07 09:40 80k 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 1、AcWing基础课: 线性筛:(与线性筛质数对应) phi[1] = 1; for (int i = 2; i <= n; i ++) { if (!st[i]) { primes[cnt ++] = i; phi[i] = i - 1; } for (int j = 0; primes[j] 阅读全文
posted @ 2022-09-06 21:45 80k 阅读(37) 评论(0) 推荐(0) 编辑
摘要: 例题: https://www.acwing.com/problem/content/description/922/ 代码: #include<bits/stdc++.h> using namespace std; int m, n; bool A_M[510][510]; int dis[510 阅读全文
posted @ 2022-09-05 16:23 80k 阅读(23) 评论(0) 推荐(0) 编辑
摘要: https://www.acwing.com/problem/content/1131/ #include<bits/stdc++.h> #define fore(x,y,z) for(LL x=(y);x<=(z);x++) #define forn(x,y,z) for(LL x=(y);x<( 阅读全文
posted @ 2022-09-04 18:14 80k 阅读(10) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 28 下一页