原创 hdu2078
看完題就想用DP做,再看discuss才意識到這題根本沒那麼麻煩 #include<iostream> #include<cstdio> using namespace std; int main(){ int t; i
原创 hdu4514 湫湫系列故事——設計風景線
求樹的最長直徑,之前做過hdu2196,套用那道題的思路,兩次dfs,求出每個結點的最長直徑,然後找出最大的即爲整棵樹的最長直徑#pragma comment(linker, "/STACK:102400000,102400000") #
原创 hdu3555 Bomb 數位DP
數位DP初學者,代碼就是網上千篇一律,相似度極高的數位DP代碼 一個不錯的題解http://www.cnblogs.com/luyi0619/archive/2011/04/29/2033117.html #include<iostre
原创 hdu1561 The more, The Better hdu1011 Starship Troopers
兩道相似的樹形dp+有依賴的的揹包,有依賴的揹包的多層依賴關係可以用樹表示出來,所以以後遇到多層依賴關係的揹包可以考慮將依賴關係表示成一棵樹,然後樹形DP求解,有依賴的揹包的求解使用到分組揹包思想,詳見揹包九講相關專題#include<i
原创 poj 1948 Triangular Pastures
#include<iostream> #include<cstring> #include<cstdio> #include<cmath> using namespace std; bool dp[45][800][800]; int a
原创 hdu3415 Max Sum of Max-K-sub-sequence
我的第一道單調隊列題目,之前有看過這道題的題解,並簡單瞭解了單調隊列,本以爲自己能獨立寫出來,戰戰兢兢寫完,一調試果然是錯的,找到了原因還是不知道該如何解決,無奈再看題解,隊列裏存的是數組下標,我存的是元素自身,這樣就不能維護子序列的長度
原创 Python完全新手教程
作者:taowen, billrice Lesson 1 準備好學習Python的環境 下載的地址是: www.python.org 爲了大家的方便,我在校內作了copy: http://10.1.204.2/tool/compiler
原创 hdu4003 Find Metal Mineral
#include<iostream> #include<cstdio> #include<cstring> #define M 10010 using namespace std; struct node{ int to,val,
原创 hdu4705 Y
非連通組合個數=所有組合-連通組合個數 樹形DP,根結點表示三個連通組合數的中間那個數#include<iostream> #include<cstring> #include<cstdio> using namespace std; #
原创 hdu 4739 Zhuge Liang's Mines
#include<iostream> #include<cstring> #include<cstdio> #include<vector> #include<algorithm> using namespace std; struct
原创 poj 3624 01揹包 水
水 #include<iostream> #include<cstdio> using namespace std; int dp[12890]={0}; int main(){ int n,m; int w,d; scanf("%
原创 poj 1276 多重揹包
一種優化方法思路來自於hdu2844 Coins #include<iostream> #include<cstdio> #include<cstring> using namespace std; bool dp[100010]; in
原创 hdu2844 Coins
在discuss裏看到的這個方法,不需要二進制優化,也不需要單調隊列優化,僅需增加一個數組記錄每個coin使用的個數,既好寫有好理解,話說那個高端大氣的單調隊列優化各種複雜抽象難以理解,膜拜ing。 #include<iostream>
原创 poj 1236 Network of Schools
#include<iostream> #include<cstdio> #include<cstring> #define N 110 #define M 5010 using namespace std; struct node{
原创 hdu2196 Computer
求樹的所有結點的最長直徑#include<iostream> #include<cstring> #include<cstdio> using namespace std; #define M 10010 int len[M],len2[