版本比较
经验随笔
正文
增加 73 行删除 3 行
29 行未改动3031323334353634353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510629 行未改动 &=n^2+\sum_{x=1}^{n}[n \mid {x^2}]\\ \end{aligned} $$
6. `1<<k` 是 `int` 类型,`1ll<<k` 才是 `long long`。[~~出生位运算~~](https://www.luogu.com.cn/record/list?pid=P4067&user=1100612) 7. [取模的常数很难绷](https://www.luogu.com.cn/record/list?pid=P13979&user=1100612) 8. 待续。6. `1<<k` 是 `int` 类型,`1ll<<k` 才是 `long long`。[~~出生位运算~~](https://www.luogu.com.cn/record/list?pid=P4067&user=1100612)
7. [取模的常数很难绷](https://www.luogu.com.cn/record/list?pid=P13979&user=1100612)
8. 对于 $a \le b \le c$,$\min(a \otimes b,b \otimes c) \le a \otimes c $
证明:设从高到低 $a \otimes b$ 与 $b \otimes c$ 第一位不同的位置 $i$。 $$ \begin{aligned} &\because a_i \otimes b_i \otimes b_i \otimes c_i=1,\\ &\therefore a_i \otimes c_i=1.\\ &\therefore a_i \otimes c_i \ge \min(a_i \otimes b_i,b_i \otimes c_i)=0.\\ &\therefore a \otimes c \ge \min(a \otimes b,b \otimes c). \end{aligned} $$
9. `link` 是一种函数的名称。
10. 乘法取模记得考虑原根+离散对数。
11. 异或既是不进位加法,也是不退位减法。
12. 质数非常密集,$10^8$ 内最大间隔为 $220$。
13. 补图最短路 $O(n+m)$```cppvoid bfs(int x){ vector<int> qwq; for(int i=1;i<=n;i++) { if(i!=x) qwq.push_back(i); dis[i]=-1; vis[i]=0; } dis[x]=0; q.push(x); while(!q.empty()) { int u=q.front(); q.pop(); for(auto v:g[u]) { vis[v]=u; } for(int i=0;i<qwq.size();i++) { int v=qwq[i]; if(vis[v]==u) continue; q.push(v); dis[v]=dis[u]+1; swap(qwq[i],qwq.back()); qwq.pop_back(); i--; } } qwq.clear();}```14. 动态规划设计状态,状态之间尽量独立。15. dp 转移时,求最大值尽量用加,最小值尽量用减,方便优化。16. 划分组 dp,差分拆贡献。17. $a_i$ 严格递增 $\iff$ $a_i-i$ 不降。18. 一种求 popcount 相同的下一个更大的数的算法:```cppint qwq(int cur){ int lb=cur&-cur; int r=cur+lb; return (((cur^r)>>2)/lb)|r;}```