- 博客(31)
- 收藏
- 关注
转载 傻牛的约数研究
【问题描述】 傻牛最近在研究约数,它觉得这玩意很牛逼。首先,对于一个数字 X 来说,设 F(X)表示 X 的约数个数,可以先将 X 表达成 为 若 干 个 质 数 的 幂 次 之 积 , 即 X=p1 k1 p2 k2 * … … ps ks , 然 后F(X)=(k1+1)(k2+1)…*(ks+1)。傻牛觉得这个碉堡了。有一天它想,我们是不是可以求出 F(1)+F(2)+F(3)+…+F(N)的值呢?结果,它晕掉了。 【输入】 输入文件名为 divisor.in。 一行一个整数 N,意义见上
2022-05-06 19:56:08
132
转载 vim配置(windows)
"~/.vimrc "vim config file "date 2018-12-26 "Created by bert "blog:http://blog.51cto.com/zpf666 """"""""""""""""""""""""""""""""""" """=>全局配置<=""" """"""""""""""""""""""""""""""""""" "关闭vi兼容模式" set nocompatible "设置历史记录步数" set history=1000 "开启相关插件"
2022-04-28 19:24:57
621
转载 求树的直径
两遍dfs #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N=100005; int n,m,t,p,ans; int d[N],first[N],v[N],w[N],next[N]; void add(int x,int y,int z) { t++; next[t]=first[x]; first[x]=t; v[t]=y; w[t]
2022-04-10 18:32:43
101
原创 LIS树状数组板子
#include <cstdio> #include <algorithm> #include <cstring> using namespace std; int C[1100]; const int MAXN = 10; void update(int x, int ans) { C[x] = ans ; while(x < MAXN){ C[x] = max(C[x] , ans) ; x += x&-x
2022-03-26 14:49:53
236
原创 拓扑图判环
拓扑图判环 使用拓扑排序判断无向图和有向图中是否存在环的区别在于: 在判断无向图中是否存在环时,是将所有度 <= 1 的结点入队; 在判断有向图中是否存在环时,是将所有入度 = 0 的结点入队。 ...
2022-03-19 15:27:58
323
原创 2022湖南多校第一场(记录)
2022湖南多校第一场3.13ABC A 签到题 B 方法一:模拟一个“回”型迷宫 w w w w w w b b b w w b w b w w w w b w b b b b w 方法二:从左上角开始模拟一个“拐角”型 w b w b w w w w b w b b w b w w w w w w b b b b w (这题hxy秒杀的,我不会qwq) C ...
2022-03-19 15:25:37
1021
原创 扫描线算法
扫描线=离散化+线段树 应用 1.面积 2.周长 思路参考 3.代码 #include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #define mid ((l+r) >> 1) #define lson (num << 1) #define rson ((num)<<1 | 1) #define LL long long using n
2022-03-16 15:28:59
662
原创 P4162 [SCOI2009]最长距离
P4162 [SCOI2009]最长距离 错误代码 #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<queue> #include<cmath> #define pii pair<int,int> using namespace std; int n,m,T; int a[33][33],b[33][33],
2022-03-09 17:17:27
667
转载 线性筛素数(欧拉筛)
线性筛素数 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cstdlib> #define in(a) a=read() #define REP(i,k,n) for(int i=k;i<=n;i++) using namespace std; inline int read(){ int x=0,f=1;
2022-03-09 15:13:38
168
转载 bitset用法
bitset小结 bitset 主要存储二进制数位。 bitset 就像一个 bool 类型的数组一样,但是有空间优化—— bitset 中的一个元素只相当于一个 char 元素所占空间的八分之一。 bitset 中的每个元素都能单独被访问,例如对于一个叫做 x 的bitset,表达式 x[3] 访问了它的第 4 个元素,就像数组一样。 bitset 有一个特性:整数类型和布尔数组都能转化成 bitset 。 运用一下: x.size() 返回大小(位数) x.count() 返回
2022-03-03 15:28:13
612
转载 博弈论总结
博弈论1.巴什博奕2.威佐夫博弈3.nim博弈(异或问题)4.斐波那契博弈5.环形博弈6. 对称博弈 都是满足条件,则后手必胜 1.巴什博奕 场景:只有一堆n个物品,两个人轮流从中取物,规定每次最少取一个,最多取m个,最后取光者为胜。 解决:一轮最多拿的就是1+m个,所以控制下去,最后的不到(1+m)的物品肯定会被后手拿到的。 2.威佐夫博弈 场景:有两堆各若干的物品,两人轮流从其中一堆取至少一件物品,至多不限,或从两堆中同时取相同件物品,规定最后取完者胜利。 解决:(黄金分割)看两个数的差值t是不是
2022-01-29 16:14:41
289
原创 LCA(倍增,Tarjan)
LCA倍增tarjan 倍增 #include<bits/stdc++.h> //#define max(a,b) (((a) > (b)) ? (a) : (b)) using namespace std; int n,T,root,deep[500010],maxdeep,f[500010][25]; int tot,h[500010],top; struct node{ int next,to; }e[2*500010]; void add(int u,int v) { ++to
2022-01-22 23:49:22
310
原创 最小生成树
最小生成树 prim #include<bits/stdc++.h> #define inf 1000000000 using namespace std; int n,m,dis[5010],ans; bool b[5010]; int tot,h[5010],nxt[400010],to[400010],cost[400010]; void add(int x,int y,int z) { ++tot; nxt[tot]=h[x]; h[x]=tot; to[tot]=y; cos
2022-01-22 17:17:52
339
原创 并查集..
1.核心思想:建立一个具有连通性质的集合 2. 实现关键:路径压缩 3.初始化:自己的父亲是自己 4. 代码 #include<bits/stdc++.h> using namespace std; const int nu=500100; struct node{ int u,v,w; }e[nu]; int f[nu],p,m,dis,k=0; int getf(int x) { if(x==f[x])return x; else return f[x]=getf(f
2022-01-22 16:32:33
346
原创 最短路(3算法)
最短路floyeddijkstraSPFA floyed 核心代码 for (i = 1; i <= n; i++){ for (j = 1; j <= n; j++){ if (e[i][j] > e[i][1] + e[1][j]) e[i][j] = e[i][1] + e[1][j]; } } dijkstra 不能有负权边 堆优化,复杂度O(nlogn) 代码 #include<bits/stdc++.h&g
2022-01-22 12:03:45
294
原创 拓扑排序DAG
拓扑排序 适用:有向无环图 使用情景:每个项目有自己的前置任务 复杂度O{N+E} 代码(noip神经网络) #include<queue> #include<cstdio> #include<algorithm> #define N 101 using namespace std; struct edge{ int to,val,nxt; } e[N*N]; struct answer{ int id,val; } ans[N]; int h,i,m,n,t,u
2022-01-22 10:44:16
226
原创 Trie字典树
每个节点有26个子节点 复杂度(n+km)k为插入字母数,m为查询数,k为深度 #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> using namespace std; int trie[400001][26],len,root,tot,sum[400001]; bool p; int n,m; char s[11]; void insert() {
2022-01-21 15:30:39
101
原创 扩展KMP算法
扩展kmp 参考博客 核心数组: next[i]: T[i]…T[m - 1]与T的最长相同前缀长度; extend[i]: S[i]…S[n - 1]与T的最长相同前缀长度。 个人理解:每次找到可以匹配的一串字符,就将其展开(a,p),在依次枚举i。而当访问超出p时,更新区间。 代码1 #include <iostream> #include <string> using namespace std; void GetNext(string & T, int &am
2022-01-20 22:42:28
364
原创 KMP算法
KMP 算法思想:从n*m的匹配结构,优化为在n上滑动,m根据预处理一步更新到位 注意:字符串是从0开始 预处理本身就是两个相同字符串的KMP过程 代码及注释 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 1e6+5; const int maxm = 1e3+5; char a[maxn],b[maxn]; int nxt[maxm]; //nxt[i]表示:当匹配
2022-01-20 14:36:27
230
原创 线段树基础
线段树关键:代码:区间加法,区间求和代码:区间加法、乘法,区间求和 关键: 数组空间4:二叉树节点数为2n-1,所有根节点下有两个空节点,所以节点数为4*n-1; lazy数组:因为修改范围已经包括整个区间,所以不再需要下放 函数模块:(build建树,down下放)+区间操作 注意:操作前下放,操作后赋值 代码:区间加法,区间求和 #include<bits/stdc++.h> using namespace std; int n,m; long long tree[400000],laz
2022-01-20 08:25:41
589
转载 树状数组(两种)
树状数组单点修改,区间查询区间修改,区间查询 单点修改,区间查询 关键:lowbit函数 核心代码 int lowbit(int x)// 取x的最小不为0的位置 { return x & -x; } void update(int x, int c) { for (int i = x;i <= n; i += lowbit(i)) tr[i] += c; } ll getsum(int x) { int res = 0; for (int i
2022-01-15 22:35:57
119
原创 Hash表(散列表)
Hash表(散列表) 复杂度O(k*n)k为较大的常数 用处:在不适用动态内存的情况下,充分利用静态内存(不需要把数组开的贼大) 判重(和map功能相似) 避免hash冲突:链地址法 代码 #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<queue> #include<stack> #include<map> #
2022-01-11 13:29:14
161
原创 简单数据结构归纳
单链表 1.插入时判断是否为结尾 2.中途插入时,先连接后面 temp->next=pre->next; //后连前面 pre->next=temp; 双向链表 1.带头结点的双链表当head->next为NULL时链表为空, 2.不带头结点的双链表当head为NULL时链表为空。 ...
2022-01-09 18:29:59
689
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅