随笔分类 -  算法模板

存一些常用的算法模板
摘要:// 求 n 的欧拉函数 int calPhi(int n) { int ret = n; int bd = std::sqrt(n); for (int i = 2; i <= n / i; ++i) { if (n % i == 0) { ret = ret / i * (i - 1); whi 阅读全文
posted @ 2023-03-07 11:15 hacker_dvd 阅读(10) 评论(0) 推荐(0) 编辑
摘要:// 模板矩阵 LL A[10][10] = { }; struct Matrix { void mul(LL a[10][10], LL b[10][10], LL c[10][10]) { LL tmp[10][10] {}; for (int i = 0; i < n; ++i) { for 阅读全文
posted @ 2023-03-06 19:55 hacker_dvd 阅读(18) 评论(0) 推荐(0) 编辑
摘要:constexpr int N = 100005; // ch[i][0] 代表左儿子,ch[i][1] 代表右儿子 int rt, tot, fa[N], ch[N][2], val[N], cnt[N], sz[N]; struct Splay { void maintain(int x) { 阅读全文
posted @ 2023-02-15 23:15 hacker_dvd 阅读(13) 评论(0) 推荐(0) 编辑
摘要:using ll = __int128; template <typename T> inline void rd(T &data) { T x = 0, flag = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch=='- 阅读全文
posted @ 2023-02-15 11:24 hacker_dvd 阅读(15) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示