原创 HDU 1166 排兵佈陣(線段樹)

題意:第一行一個整數T,表示有T組數據。每組數據第一行一個正整數N(N<=50000),表示敵人有N個工兵營地,接下來有N個正整數,第i個正整數ai

原创 HDU 1233 還是暢通工程(並查集)

解析:本題要求找出各城鎮的最小連通圖,根據克魯斯卡爾算法,將最小權值且不構成迴路的點全部連起來,最終計算出連起來的邊的權值即爲答案。 #include<cstdio> #include<iostream> #include<cstdlib

原创 HDU 1232 暢通工程(最小生成樹)

題目分析:本題主要是要找出有幾個點是獨立的,沒有連通的,因此本題才用並查集的方法最佳。 #include<cstdio> #include<iostream> using namespace std; int father[100

原创 HDU 1010 Tempter of the Bone(深搜)

題意: Input: The input consists of multiple test cases. The first line of each test case contains three integers N, M, a

原创 HDU 1312 Red and Black(深搜)

題意: There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing

原创 HDU 1047 大數相加

題意: Input: The input will consist of at most 100 lines of text, each of which contains a single VeryLongInteger. Each V

原创 HDU 1241 Oil Deposits(深搜)

題意: The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works wi

原创 POJ 2528 Mayor's posters(線段樹)

題目大意:在牆壁上貼廣告,廣告的版面有大有小,並且貼廣告有先後之分,後面貼的廣告會覆蓋前面的廣告,求解最後能看到的廣告面 題目分析 更新的基本原理就是,當我們貼海報i時,如果遇到某一線段區間能夠被當前海報完全覆蓋,那麼我們更新到此

原创 POJ 2560 Freckles(最小生成樹)

題目大意:有n個點,並且知道它們的座標,求連接所有點的最短路徑。 題目分析: 算法:prime算法 1.任選一個點,加入樹中,作爲第一個樹中的點。 2.取距離現有樹距離最小的點,加入樹中。 3.重複步驟2, 直至所有點都加入到樹中。

原创 HDU 3308 LCIS(線段樹)

題目: Input: T in the first line, indicating the case number.Each case starts with two integers n , m(0<n,m<=105).The nex

原创 HDU 1195 Open the Lock(廣搜)

題目: Now an emergent task for you is to open a password lock. The password is consisted of four digits. Each digit is nu

原创 HDU 1518 Square(深搜)

題目: Given a set of sticks of various lengths, is it possible to join them end-to-end to form a square? The first line o

原创 HDU 3577 Fast Arrangement(線段樹)

題意:input: The input contains servel test cases. The first line is the case number. In each test case:The first line con

原创 HDU 1016 Prime Ring Problem(深搜)

#include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> using namespace std; int fun1(int a,int b[]) {

原创 HDU 2608 0 or 1(數論)

題目: define T(n) as the sum of all numbers which are positive integers can divied n. and S(n) = T(1) + T(2) + T(3)…..+T(