06 2020 档案
摘要:探索一门学问有三个层次:求其解,知其原因,究其思维之本。通俗地讲,就是“怎么做” “为什么是对的” “怎样才能想到怎么去做”。在计算机科学中,前两者分别对应算法的步骤和证明。而长久以来,后者时常与“天赋”一词相关联。在全面讲解算法与数据结构知识点的同时,致力于模型构建与思路分析,帮助我们厘清思维过程
阅读全文
摘要:CF3A Shortest path of the king Luogu题地址 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> using namespace
阅读全文
摘要:P3378 【模板】堆 #include <iostream> #include <cstring> #include <cstdio> using namespace std; const int N = 1e6; int h[N], s; void up(int u) { while(u / 2
阅读全文
摘要:P3375 【模板】KMP字符串匹配 #include <iostream> #include <cstring> #include <cstdio> using namespace std; const int N =1e6 + 10; char s[N], p[N]; int ne[N]; in
阅读全文
摘要:P3366 【模板】最小生成树 //prim算法求最小生成树#include <iostream> #include <cstring> using namespace std; const int N = 5010, INF = 0x3f3f3f3f; int n, m, d[N], g[N][N
阅读全文
摘要:P3370 【模板】字符串哈希 #include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <cstdio> using namespace std; typedef unsigned
阅读全文
摘要:【模板】快速排序 #include <iostream> using namespace std; const int N = 1e5 + 10; int a[N]; void qsort(int l, int r) { if(l >= r) return; //边界边界,莫要忘了 int i =
阅读全文
摘要:朴素快速幂 快速幂思想优化点:由于计算机二进制数的位运算效率高, 我们将指数用二进制数表示eg. 3^15 = 3^(1111)3^15 = 3 * 3 * … * 3;3^(1111) = 3^(2^3) * 3^(2^2) * 3(2^1) * 3(2^0);3 2 1 0(快速幂基本语句执行次
阅读全文
摘要:P3367 【模板】并查集 #include <iostream> #include <cstring> using namespace std; const int N = 1e4 + 10; int p[N], n, m; int find(int x) { if(p[x] != x) p[x]
阅读全文
摘要:【模板】单源最短路径 题目传送门:P3371 【模板】单源最短路径(弱) //1、朴素版Dijkstra #include <iostream> #include <cstring> using namespace std; const int N = 2001, INF = 0x3f3f3f3f;
阅读全文
摘要:分治算法 所谓分治就是指分而治之,即将较大规模的问题分解成几个较小规模的问题,通过对较小规模问题的求解达到对整个问题的求解。当我们将问题分解成两个较小问题求解时的分治方法称之为二分。 你们玩过猜数字的游戏吗?你的朋友心里想一个 1000 以内的正整数,你可以给出一个数字 x ,你朋友只要回答“比 x
阅读全文