原创 二叉樹的重建

給定前序序列和中序序列,唯一確定一棵二叉樹; 給定後序序列和中序序列,按層次序列和中序序列可以也可以唯一確定一棵二叉樹。 但是,如果知道二叉樹的先序序列和後序序列,則無法唯一確定一棵二叉樹。 輸入:(前序遍歷與中序遍歷) 5

原创 歸併排序

歸併排序: 歸併排序:對一個數組不斷進行分半分割,直到分爲單個元素,然後依次比較左邊元素與右邊元素(即相鄰區間的元素)的大小進行排序,放到一個新的數組中。 歸併過程爲:比較L[i](左邊)和R[j](右邊)的大小,若L[i]≤R[

原创 hdu_1710_Binary Tree Traversals(二叉樹的重構)

Description A binary tree is a finite set of vertices that is either empty or consists of a root r and two disjoin

原创 HDU - 1394 _Minimum Inversion Number(歸併排序求逆序數)

Description The inversion number of a given number sequence a1, a2, …, an is the number of pairs (ai, aj) that sat

原创 計蒜客—最長不重複子串(字符串)

給定一個字符串,找到最長的子串,要求該子串中沒有重複的字符。例如:字符串abcabcbb的不含重複字符的 最長 子串爲abc,長度爲 33。而bbbbbb的不含重複字符的 最長 子串爲b,長度爲 11。輸入格式輸入包含多行,每一行對應一個

原创 poj_1321_棋盤問題(深搜,不同行不同列)

棋盤問題Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 59097 Accepted: 28382Description在一個給定形狀的棋盤(形狀可能是不規則的)上面擺放

原创 poj_3258_River Hopscotch(二分搜索,最下最大問題)

River HopscotchTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 17792 Accepted: 7437DescriptionEvery year the

原创 SDUT3899_sum of power(大數問題)

                                                    sum of power                                                Time Li

原创 poj_1064_Cable master(二分搜索,最大最小/最小最大)

Cable masterTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 58900 Accepted: 12275DescriptionInhabitants of th

原创 Java大數有關的知識

大數:BigInteger 和 BigDecimal分別表示大整數類和大浮點數類。這兩個類都在java.math.*包中,因此每次必須在開頭處引用該包一、大數的基本運算:以整數爲例實現 BigInteger

原创 Java字符串整理

一、字符串的輸入與轉換:in.next(); //到空格就結束in.nextLine();String str = new String();1.一維:(1)空格不當做字符串的: String g[] =

原创 poj_3045_Cow Acrobats(二分搜索)

Cow AcrobatsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 6266 Accepted: 2349DescriptionFarmer John's N (1

原创 poj_3273_Monthly Expense(二分搜索,最小花費)

Monthly ExpenseTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 32155 Accepted: 12113DescriptionFarmer John is

原创 poj_2456_Aggressive cows(二分搜索----最大最小/最小最大問題)

Aggressive cowsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 18363 Accepted: 8740DescriptionFarmer John has

原创 poj_3278_Catch That Cow(搜索廣搜)

Catch That CowTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 109183 Accepted: 34100DescriptionFarmer John ha