st算法 求區間最值問題

算法的一個實現方法以下。html 其中使用位運算替代2的冪次的計算,加快運算速度。算法 使用時須要先調用initRMQ()進行初始化,而後再調用RMQ(u,v)進行查詢。數組 1 const int mx = 10000 + 10; //數組最大長度 2 int n, a[mx]; //數組長度,數組內容 3 4 int st[mx][30]; //DP數組 5 void initR
相關文章
相關標籤/搜索