原创 最小覆蓋 Machine Schedule POJ 1325

每個工作用一條邊代表,用最小的點覆蓋所有的邊,也就是找出最小覆蓋。 公式:最小覆蓋=最大匹配;對原二分圖做一次最大匹配 #include<iostream> using namespace std; const int MAX=1005;

原创 POJ 2777 Count Color 線段樹一些容易遺漏的東西……

成段更新,區間統計, 把query裏的傳遞給子節點的步驟,切記!! 向大牛學習……http://www.notonlysuccess.com/?p=59 #include<iostream> using namespace std; in

原创 Timus 1022. Genealogical tree 拓補排序

#include <iostream> using namespace std; #include <string> int main() { freopen("in.txt","r",stdin); int n; int t

原创 轉載關於計算二進制數中1的個數

求二進制數中1的個數(摘)寫一個函數,返回數字中二進制位爲'1'的個數。比如36,化爲二進制得到100100,其中有2個'1'。方法1:分別判斷各個位int bit_count(unsigned int n){ int count;

原创 timus graph theory

1056 Computer net #include<iostream> #include <stack> using namespace std; int n; int m,k; int a[10002][100]; int c[100

原创 轉載一篇關於Map 的總結

   Map是c++的一個標準容器,她提供了很好一對一的關係,在一些程序中建立一個map可以起到事半功倍的效果,總結了一些map基本簡單實用的操作!1. map最基本的構造函數;   map<string , int >mapstring

原创 RQNOJ 311

  #include<iostream> using namespace std; long long best[41][31]; long long a[41][31]; int main( ) { freopen("in.txt",

原创 RQNOJ 329 二維揹包 順便收集整理一下相關資料

今天做這題,wa了很多次。原來是01揹包沒學好。 以下是優化空間複雜度後的程序 #include<iostream> #include<algorithm> using namespace std; const int maxn=200;

原创 二分圖最大基數匹配 POJ 1274 The Perfect Stall

最簡單的二分圖匹配,第一次寫增廣路算法。 #include<iostream> using namespace std; const int MAX=205; bool map[MAX][MAX]; int match[MAX]; boo

原创 最小環 timus1004

看了別人的代碼才寫出來的…… 這裏修改了floyd算法。 floyd算的最外層循環,循環k層結束時,dis[i][j]表示i 到 j 的最短距離,之間的點序號不大於 k 。       #include<iostream> #includ

原创 高精度乘法,支持浮點運算。POJ 1001 Exponentiation 順便總結一下string的常用函數

第一次使用string的insert() 函數,該函數有好幾個重載,所以在傳參數時要明確地給予類型轉換。 插入(insert) 語法: iterator insert( iterator i, const char &ch );basic

原创 多重揹包

多重揹包問題 問題:有N種物品和一個容量爲V的揹包。第i種物品最多有n[i]件可用,每件體積是v[i],重量是w[i]。求解將哪些物品裝入揹包可使這些物品的體積總和不超過揹包容量,且重量總和最大。 for (int i=0; i<=V;

原创 usaco /money

/*PROG: moneyID: daxiong1LANG: C++*/#include<iostream>#include<fstream>using namespace std;long long aa[26][10001];long

原创 Timus 1225. Flags dp

1225. FlagsTime Limit: 1.0 secondMemory Limit: 16 MBOn the Day of the Flag of Russia a shop-owner decided to decorate t

原创 揹包 dp 雙重動態規劃

Raucous Rockers“破鑼搖滾”樂隊譯 by Maigo Akisame你剛剛繼承了流行的“破鑼搖滾”樂隊錄製的尚未發表的N(1 <= N <= 20)首歌的版權。你打算從中精選一些歌曲,發行M(1 <= M <= 20)張