Fast Power Algorithm / Fast Matrix Exponeitation
Part 1 Just only number.We know xa+b = xa * xb.e.g. 513 = 58 x 54 x 51So we have this code:long double myPow(long double x, int pow) {
bool flag=0;
if (pow<0)
flag=1, pow=-pow;
...
Network Flow Template (SAP)
This algorithm was named for Shortest Augmenting Path (SAP).. From an OIer, at about year 2010.IntroductionTotal of n nodes, m edges.S is source node means 'source'.T is sink node means 'target'.m...
Treap
简介Treap is Tree + Heap, each node have two property : Key, and Priority.Using key can format the Binary tree, and using Priority can make a heap.代码struct Treap {
int key,pri;
int cnt;
T...
Heap+Dijkstra
练习题:http://poj.org/problem?id=3169Dijkstra的过程InitializationSet dist[all]=∞ and set dist[S]=0;
push S into Heap;Mainwhile (!heap.empty()) {
HeapItem p=heap.pop();
if (dist[p] != p.distence) ...