Golang
Golang数据类型声明12var name type = valuename := value // name 未使用过
转换1int32(8) // int float 都适用
$\rightarrow string$ 转换
方式一:$fmt.Sprintf()$
123456789101112131415161718192021222324252627fmt.Sprintf("%参数", 表达式) bool%t the word true or falsedigit%b base 2%c the character represented by the corresponding Unicode code point%d base 10%o base 8%O base 8 with 0o prefix%q a single-quoted character literal safely escaped with Go syntax.%x base 16, with lower-case letters for a-f%X base 16, with ...
HTML
HTML使用 $html5$
1<!DOCTYPE html>
html$language$
1<html lang="zh">...</html>
head编码1<meta charset="UTF-8">
title更改标题
12345<head> <title> Learning HTML </title></head>
body排版标题123456789101112131415161718<h1>一级标题</h1><h2>二级标题</h2><h3>三级标题</h3><h4>四级标题</h4><h5>五级标题</h5><h6>六级标题</h6>
段落123<p>段落</p>
划分div 分割划分作用
1<div& ...
JavaScript
JavaScript编写 $javascript$ 。
12345678<script type="text/javascript"> // 浏览器弹窗 alert("tips"); // 向 body 输出 document.writeln("something") // 向控制台输出 console.log("It is console")</script>
运行外部文件(引入 $src$ 后 $script$ 中内容就无效)。
1<script type="text/javascript" src="extern.js"></script>
Variable声明12var a = 10var name = value
typeof输出变量类型。
1234var a = 10console.log(typeof a)a = "sedrt"con ...
CSS
CSS(引入)样式一般在 <head> 中。
样式位置行内样式写在标签 style 中, 名:值; 。(优先级最高)
1<h1 style="color: pink; font-size: 25px;">CSS STYLE LEARNING</h1>
样式简单才使用。
内部样式<style>...</style>
1234567891011121314151617181920<style>h1{ color: pink; font-size: 40px;}h2{ color: blue; font-size: 25px;}p{ color: red; font-size: 10px;}img{ width: 200px;}</style>
1234<!-- 内部样式 --><h2>Let us start</h2>&l ...
Poly
PolypolynomialIntroDegree对于一个多项式 $f(x)$,称其最高次项的次数为该多项式的 度(degree),也称次数,记作 $\operatorname{deg}{f}$。
Composite定义 $R[[x]]$ 中元素 $f$ 的乘方为
$$f^1=f,f^k=f^{k-1}\times f$$
在此基础上,定义 $R[[x]]$ 中元素 $f,g$ 的复合为
$$(f\circ g)(x)=f(g(x))=f_0+\sum_{k=1}^{+\infty}f_kg^k(x)$$
Derivative尽管一般环甚至未必存在极限,我们依然可以定义形式幂级数的 形式导数(formal derivative)为$$\left(\sum_{k=0}^{+\infty}f_kx^k\right)’=\sum_{k=1}^{+\infty}kf_kx^{k-1}$$
Inverse对于形式幂级数 $f$,若 $f_0\not=0$,其 乘法逆元(multiplicative inve ...
Number theory
Number theoryInverse$ax \equiv 1$ $(mod \quad n)$
逆元存在的充要条件 $gcd(a, n) = 1$
$n$ 是质数且 $gcd(a, n) = 1$,逆元 $x \equiv a^{n - 2} \quad (mod \quad n)$ (费马小定理)
$ax + ny = gcd(a, n)$,$gcd(a, n) = 1$ ,求 $x$ 的最小正整数解 (Exgcd 求解)
线性递推 $1,2,\cdots,n$ 的逆元:$inv_{i} = (p - \lfloor \frac{p}{i} \rfloor ) \times inv_{p ; mod ; i} \quad mod ; p$
1234inv[1] = 1;for (int i = 2; i <= n; ++i) { inv[i] = (long long)(p - p / i) * inv[p % i] % p;}
计算任意 $n$ 个数的逆元,先求前缀积 $S_{n} ...
Graph
GraphTree树链剖分重链剖分12345678910111213141516171819202122232425262728293031323334353637// get fa, siz, dep, sonvector<int> fa(n + 1), siz(n + 1), dep(n + 1), son(n + 1);auto dfs = [&](auto self, int u, int f) -> void { int s = 0; fa[u] = f; siz[u] = 1; dep[u] = dep[f] + 1; for (auto& v : tree[u]) { if (v != f) { self(self, v, u); siz[u] += siz[v]; if (siz[v] > siz[s]) { s = v; ...
Data Structures
Data StructuresDSU普通并查集12345678910111213141516171819202122232425262728293031323334353637383940struct DSU { std::vector<int> f, siz; DSU() {} DSU(int n) { init(n); } void init(int n) { f.resize(n); std::iota(f.begin(), f.end(), 0); siz.assign(n, 1); } int find(int x) { while (x != f[x]) { x = f[x] = f[f[x]]; } return x; } bool same(int x, int y) { ...
String
StringHashPrimes table
1E3
1E6
1E9
1E18
1009
1000003
1000000021
1000000000000000003
1013
1000033
1000000033
1000000000000000009
1019
1000037
1000000933
1000000000000000031
1021
1000039
1000000993
1000000000000000079
Random Hash12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455// 随机 hashstd::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());const vector<int> MOD = { 1000000021, 1000000033, ...
2022 Hangzhou M. Please Save Pigeland
M. Please Save Pigeland$$求 Min(\frac{\sum dis_{x, c_{i}}}{gcd \lbrace dis_{x, c_{i}} \rbrace } )$$
$$gcd(a_{1}, a_{2}, …, a_{n}) = gcd(a_{1}, a_{2} - a_{1}, …, a_{n} - a_{1})$$
分子/母两部分可用换根 DP 计算
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341 ...