原创 樹狀數組模板(轉)

轉 樹狀數組模板區間更新 區間詢問

原创 數論

https://blog.csdn.net/weixin_43093481/article/details/82229718

原创 差分約束系統

差分約束系統的解法如下: 1、  根據條件把題意通過變量組表達出來得到不等式組,注意要發掘出隱含的不等式,比如說前後兩個變量之間隱含的不等式關係。 2、  進行建圖: 首先根據題目的要求進行不等式組的標準化。 (1)、如果要求取最小值

原创 數據結構:鏈式前向星

鏈式前向星是一種類似鄰接表,採用靜態數組模擬鏈表的數據結構 一、建立邊結構體: struct Edge { int to, cost, next }edge[maxn]; 建立數組head[]:head[i]存儲以i爲起點的第一

原创 曼哈頓距離與切比雪夫距離的轉換

曼哈頓距離與切比雪夫距離及其相互轉化 曼哈頓距離:|x1-x2| + |y1-y2| 切比雪夫距離: max(|x1-x2|,|y1-y2|) 曼哈頓轉切比雪夫: x’=x+y y’=x-y 切比雪夫轉曼哈頓: x’=(x+y)/2

原创 最短路

int dijkstra(int s, int e) { priority_queue<P, vector<P>, greater<P>> q; memset(d, 0x3f, sizeof(d)); d[s] = 0; q.

原创 Miller-Rabin long long 範圍的素數判斷

原文:https://blog.csdn.net/nobleman__/article/details/79622912?utm_source=copy #include <bits/stdc++.h> using namespace

原创 BM遞推板子

杜教板子,用於線性遞推 #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <vector> #include <st

原创 3階魔方的處理

#include<stdio.h> #include<string.h> using namespace std; int T,deep; char s[60] ; int cent[7] = {5,23,26,29,32,50} ;

原创 最大流

struct Edge { int from, to, cap, flow; Edge(int u, int v, int c, int f) : from(u), to(v), cap(c)

原创 樹狀數組模板(轉) 樹狀數組模板區間更新 區間詢問

https://blog.csdn.net/lawrence_jang/article/details/8054173 轉 樹狀數組模板區間更新 區間詢問 14、樹狀數組 (1)、單點增減+區間求和 思路:C[x]

原创 數學公式

1∗n+2∗(n−1)+3∗(n−2)+......+n∗1=n∗(n+1)∗(n+2)61∗n+2∗(n−1)+3∗(n−2)+......+n∗1=n∗(n+1)∗(n+2)6 12+22+32+......+n2=n∗(n+1)

原创 關於自增符的運算

首先,自增分爲前置和後置:++i和i++。 在單獨成式的情況下,兩者並沒有什麼區別,都是把i+1的值賦給i 但在表達式中,兩者有明顯的區別。 例如 int i = 1, j = 1; int a, b; a =

原创 哈希(HASH)-康託展開

康託展開是一個全排列到一個自然數的雙射,常用於構建hash表時的空間壓縮。設有n個數(1,2,3,4,…,n),可以有組成不同(n!種)的排列組合,康託展開表示的就是是當前排列組合在n個不同元素的全排列中的名次。 公式:X=a[n](n

原创 求逆元

(1)擴展歐幾里得 LL exgcd(LL a, LL b, LL &x, LL &y) { if (b == 0) { x = 1; y = 0; return a;