hdu1532 & pku1273 Drainage Ditches 網路流(最大流EK演算法)

hdu1532 &pku1273  Drainage Ditches(最大流EK演算法) 本題的演算法流程1.初始化pre2.BFS求增廣路徑P     不存在:break ,return flow;3.求P中最小值aug4.修改P中殘留容量,流flow++++ 需要注意:1°BFS找增廣路徑2°首碼數組pre的遍曆  //pku1273 hdu1532#include<stdio.h>#include<string.h>#define V 300#define

HDU-2199 二分法

二分法求方程的根/* * hdu-2199 can you solve the equatino * mike-w * 2012-4-17 * */#include<stdio.h>#include<stdlib.h>#include<string.h>#include<math.h>#define EPS (1e-6)#define nDISP_X1_X2const int co[10]={8,7,2,3,6};double

hdu2544 bellmanford實現

//hdu2544 #include <iostream>#define Infinity 0x3f3f3f3fusing namespace std;struct Edge_Node{int s,e,c; //start end cost }g[10005];int dist[105]; //起點到每個點的最短距離void Bellman_Ford(int n,int m)

hdu4268 排序貪心Alice and Bob

hdu4268multiset中upper_bound的使用//multiset//iterator lower_bound( const key_type &key ): 返回一個迭代器,指向索引值>= key的第一個元素。//iterator upper_bound( const key_type &key ):返回一個迭代器,指向索引值> key的第一個元素。

hdu2516取石子

hdu2516234(-1)                解釋4 - 1 = 3 , n==3為必敗點,所以4為必勝點56(-1)7(-2)89(-1)10(-2)11(-3)12(-1)  13然後就是費伯納西……#include<iostream>using namespace std;int num[50];void init(){ int i; num[1]=1;num[2]=2; for(i=3;i<=45;i++)

PKU3518 Prime Gap

prime gap僅以素數開頭和結束的序列      例如:13 14 15 16 17      (長度為17-13=4)  給定一個整數k  ,輸出包含 k 的prime gap的長度。 如果k是素數 ,輸出0  #include<iostream>#include<math.h>using namespace std;bool Isprime(int n) //素數判斷{ int i = 0; for(i = 2; i &

hdu1282迴文數猜想

hdu1282迴文數猜想  字串的操作太弱了。。。。花了將近3個小時,還好一次就過了 不然真的會瘋掉  #include<iostream>using namespace std;int main(){char x[20],y[20],t[100][20];int

HDU-1068 最大獨立集

二分圖解之,1000+ms,效率不是很高。匈牙利不夠快?/* * HDU-1068 boys and girls * mike-w */#include<stdio.h>#include<stdlib.h>#include<string.h>#define SIZE 1000int f[SIZE][SIZE];int match[SIZE];int tag[SIZE];int N;int search(int node){int i;for(i=0;i<

hdu2079-選課時間

hdu2079還是母函數的模板#include<iostream>using namespace std;int main(){int

hdu1205 吃糖果解題思路

仔細想想其實不那麼難的把最多的那種 M(共計max個) 擺成一列,產生max-1個間隔,對於M來說,其他的糖果都是異類 (共計 sum-max個),可以用來填充間隔,但是如果sum-max<max-1的話,間隔不能被填滿,所以會有相鄰的M,不符合要求 printf("No\n");當sum-max>=max-1時,M的間隔一定能被填滿  printf("Yes\n");注意sum數值較大 在異類中任選一種糖果N (N<=sum-max) 填進間隔 ,之後M與N合并代替之前的M。

hdu1035 Robot Motion 類比

mp[r] [c] [0]儲存 地圖上(r,c) 的方向如下                   N(8)       W(4)                E(6)                   S(2)mp[r] [c] [1]儲存點(r,c)被經過的次數 當第三次遇到(r,c)是不再繼續否則mp[r] [c] [1]++  #include<iostream>using namespace std;int main(){int

POJ-1088 記憶化搜尋

經典題目。/* * POJ-1088 滑雪 * mike-w * 2011-10-23 * ------------------------ * 記憶化搜尋 */#include<stdio.h>#include<stdlib.h>#include<string.h>#define SIZE 111int field[SIZE][SIZE];int opt[SIZE][SIZE];int R,C;int d[4][2]={{1,0},{-1,0},{0,1},

hdu2036 求多邊形面積

題目:

積木城堡 題解

XC的兒子小XC最喜歡玩的遊戲用積木壘漂亮的城堡。城堡是用一些立方體的積木壘成的,城堡的每一層是一塊積木。小XC是一個比他爸爸XC還聰明的孩子,他發現壘城堡的時候,如果下面的積木比上面的積木大,那麼城堡便不容易倒。所以他在壘城堡的時候總是遵循這樣的規則。小XC想把自己壘的城堡送給幼兒園裡漂亮的女孩子們,這樣可以增加他的好感度。為了公平起見,他決定把送給每個女孩子一樣高的城堡,這樣可以避免女孩子們為了獲得更漂亮的城堡而引起爭執。可是他發現自己在壘城堡的時候並沒有預先考慮到這一點。所以他現在要改造城

hdu1754 i hate it 的錯誤碼

題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=1754         Runtime Error(ACCESS_VIOLATION) 哪出錯了- - //hdu1754建樹creat 修改modify 尋找search #include<iostream>using namespace std;#define Max 400100int MAX;typedef struct node{int l,r,max;node *left,*

HDU-3790 最短路 SPFA

貢獻若干WA,原來是讀入資料出錯了==!還是要細心啊,栽在此等水題上……/* * hdu-3790 * mike-w * 2012-4-7 */#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAX_SIZE 1024#define Q_SIZE 1024#define INF (1<<30)int f[MAX_SIZE][MAX_SIZE],g[MAX_SIZE][MAX_

hdu 1024 Max Sum Plus Plus–DP

/*問題: 給定由n個整數(可能為負整數)組成的序列dat1,dat2,…,datn,以及一個正整數m,要求確定序列的m個不相交子段,使這m個子段的總和達到最大。 分析: 設d(i,j)表示數組dat的前j項中i個子段和的最大值,且第i個子段含dat[j]。以下稱d(i, j)為“最後一個元素屬於第i子段的j元素i子段問題”。則n個元素中求i個子段的最優值顯然為: d(i,j) = Max{ d(i, j-1) + dat[i], Max{ d(i-1, t) } + dat[i] } (i &

一道母函數的模板題 (hdu 2082)

終於算弄明白母函數是什麼東西了 = = , 呼~ 感覺它利用了高中學的二項式定理(就是用到組合數的那個) 完完全全的利用啊~~!以前用二項式求出最後那超長的x的運算式( 1 + C(n,1)*x^1 + C(n,2)*x^2 +~~~~~+ C(n,n-1)*x^(n-1) + C(n,n)*x^n  )之後好歹還會給x賦個值算個答案到母函數這連賦值都省了……x就代表一個實體,⊙﹏⊙b汗 它只汲取了二項式定理的精華,從每個因子中的取一個係數進行組合的思想。至於怎麼實現的 ,給兩個傳送門 

HDU-1171 多重背包

簡單的多重背包。我想先把HDU上背包問題AC掉 /* * hdu-1171 big event in hdu * mike-w * 2011-10-10 * ------------------------- * 多重背包 */#include<stdio.h>#include<stdlib.h>#include<string.h>#include<assert.h>#define MAXW 999999#define MAXN 50long

HDU-1541 樹狀數組(基礎題)

來源資料關於y座標遞增,所以只需統計x座標小於給定座標的數目作為星等。/* * hdu-1541 stars * mike-w * 2011-12-9 * ------------------- * tag: * 樹狀數組 */#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>using namespace std;const int

總頁數: 61357 1 .... 21000 21001 21002 21003 21004 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.