原创 POJ 3070 Fibonacci (矩陣快速冪基礎題)

題目鏈接:http://poj.org/problem?id=3070 創建如下矩陣求解遞推式Fn項的值: 代碼如下: #include <cstdio> #include <cstring> const int mod = 1

原创 hdu 2544 最短路 (Dijstra + Heap優化)

題目鏈接:HDU 2544 #include <cstdio> #include <cstring> #include <queue> using namespace std; const int maxn = 11111; con

原创 NYIST 143 第幾是誰?(逆康託展開)

康拓展開見:http://blog.csdn.net/vikotse/article/details/12795759 維基百科介紹見:http://zh.wikipedia.org/zh/%E5%BA%B7%E6%89%98%E5%B1

原创 算法複雜度漸近符號總結

本文根據算法導論第三章總結,但其中加入了我對本章的一些補充,並且配合算法導論習題進行講解。 相信本文會讓你對漸近記號有更深入地理解。 一、定義介紹 對於某個比較簡單的算法,我們有時候確實能夠精確地分析出算法的複雜度,比如算法複雜度爲

原创 POJ 2503 Babelfish

題目鏈接:http://poj.org/problem?id=2503 #include <cstdio> #include <cstring> #define MAXSIZE 150000 //#define maxn 30 #de

原创 HDU 1496 Equations

題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=1496 #include <cstdio> #include <cstring> int hash[2001000], p[101];

原创 Light OJ 1096 nth Term (矩陣快速冪)

題目鏈接:http://www.lightoj.com/volume_showproblem.php?problem=1096 遞推矩陣如下: 代碼如下: #include <cstdio> #include <cstring>

原创 C語言運算符優先級和口訣

一共有十五個優先級:  1   ()  []  .  -> 2   !  ~   -(負號) ++  --   &(取變量地址)*   (type)(強制類型)    sizeof  3   * / % 4   + -  5   >> <

原创 深入理解C/C++ [Deep C (and C++)]

作者:Rockics 來源:http://blog.csdn.net/rockics/article/details/7015067 說明:譯自Deep C (and C++) by Olve Maudal and Jon

原创 HDU 1520 Anniversary party (基礎樹形DP)

題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=1520 #include <cstdio> #include <vector> #include <algorithm> using na

原创 hdu 1251 統計難題(字典樹)

題目鏈接:hdu 1251 解法:構造一個字典樹,根據給出模式串統計字典樹上的結點分別被多少個單詞覆蓋到,統計到的某結點的ch值便是以該結點結尾的字符串爲前綴的單詞個數。 代碼如下: #include <cstdio> #includ

原创 POJ 1200 Crazy Search (RKhash)

題目鏈接:http://poj.org/problem?id=1200 RKhash 把每個子串轉爲nc進制再hash RKhash 詳解:http://www.cnblogs.com/cobbliu/archive/2012/05/2

原创 HDU 4686 Arc of Dream (矩陣快速冪)

題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=4686 根據題意可得: 遞推矩陣如下: 代碼如下: #include <cstdio> #include <cstring> c

原创 hdu2578 Dating with girls(1) (二分 || map)

題目鏈接:點擊打開鏈接 在這題中使用二分查找比使用map查找更快 二分查找法代碼如下(625ms): #include <cstdio> #include <algorithm> using namespace std; cons

原创 C/C++小記

scanf 的返回值爲接收到的變量值的個數 printf 的返回值爲printf 控制輸出的字符數(輸出%s時不計\0) 點贊 收藏 分享 文章舉報 Viko_ReCode 發