原创 數據結構中哈夫曼樹水題代碼

描述: 寫一個哈夫曼碼的編/譯碼系統,要求能對要傳輸的報文進行編碼和解碼。構造哈夫曼樹時,權值小的放左子樹,權值大的放右子樹,編碼時右子樹編碼爲1,左子樹編碼爲0.   輸入: 輸入表示字符集大小爲n(n <= 100)的正整數,以

原创 hdu4126 prim+樹形dp

Genghis Khan(成吉思汗)(1162-1227), also known by his birth name Temujin(鐵木真) and temple name Taizu(元太祖), was the founder of

原创 BZOJ1026 [SCOI2009] windy數

Description   windy定義了一種windy數。不含前導零且相鄰兩個數字之差至少爲2的正整數被稱爲windy數。 windy想知道, 在A和B之間,包括A和B,總共有多少個windy數? Input

原创 hdu5444 Elven Postman 二叉樹遍歷

Elves are very peculiar creatures. As we all know, they can live for a very long time and their magical prowess are not

原创 HDU 3415-Max Sum of Max-K-sub-sequence 單調隊列

Given a circle sequence A[1],A[2],A[3]......A[n]. Circle sequence means the left neighbour of A[1] is A[n] , and the

原创 POJ-1182 食物鏈

Description 動物王國中有三類動物A,B,C,這三類動物的食物鏈構成了有趣的環形。A吃B, B吃C,C吃A。  現有N個動物,以1-N編號。每個動物都是A,B,C中的一種,但是我們並不知道它到底是哪一種。  有人用兩種

原创 hdu1269 強連通分量tarjan

Problem Description 爲了訓練小希的方向感,Gardon建立了一座大城堡,裏面有N個房間(N<=10000)和M條通道(M<=100000),每個通道都是單向的,就是說若稱某通道連通了A房間和B房間,只說明可以通過這

原创 poj2001 Shortest Prefixes trie樹

Description A prefix of a string is a substring starting at the beginning of the given string. The prefixes of "car

原创 UVA - 10537 The Toll! Revisited dijkstra反向

Sindbad the Sailor sold 66 silver spoons to the Sultan of Samarkand. The selling was quite easy; butdelivering was comp

原创 POJ2728 Desert King 最優比率生成樹

David the Great has just become the king of a desert country. To win the respect of his people, he decided to build

原创 八數碼問題--A*算法

hdu1043:#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<queue> using namespace std;

原创 poj1509 字符串最小表示法

題意就是給一個環形字符串,求在哪裏斷開可以得到字典序最小的字符串 經典的字符串最小表示法 #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #in

原创 HDU1251統計難題 trie樹

Description Ignatius最近遇到一個難題, 老師交給他很多單詞( 只有小寫字母組成, 不會有重複的單詞出現),現在老師要他統計出以某個字符串爲前綴的單詞數量( 單詞本身也是自己的前綴). Input 輸入數

原创 hdu4430 Yukari's Birthday 枚舉+二分

Today is Yukari's n-th birthday. Ran and Chen hold a celebration party for her. Now comes the most important part, bi

原创 UVA11374_Airport Express

In a small city called Iokh, a train service, Airport-Express,takes residents to the airport more quickly than other tr