hdu 1540 线段树 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1540题意:有n个点依次链接,先给出三种操作:删除某个点 修复某个点 查询与某个点相连的点的个数解法:主要是query函数的写法。利用回溯,分情况判断左/右是否联通。注意自定义的结构一定要赋初值。 #include iostream>#include s
poj 3468 A Simple Problem with Integers【线段树】 #include #include #include #include #include #include #include #include #include #include #define L(x) (x<<1)#define R(x) (x<<1|1)#define P(x) (x>>1)#define LL long long#define PAUSE sys
hdoj 2795 Billboard 【线段树】 #include #include #include #include #include #include #include #include #include #define L(x) (x<<1)#define R(x) (x<<1|1)#define P(x) (x>>1)#define PAUSE system("pause)using namespace std
hdoj 1698 Just a Hook 【线段树】 #include #include #include #include #include #include #include #include #include #define L(x) (x<<1)#define R(x) (x<<1|1)#define P(x) (x>>1)#define PAUSE system("pause)using namespace std
hdoj 1754 【线段树】 #include #include #include #define LS(x) (x<<1)#define RS(x) (x<<1|1)#define P(x) (x>>1)#define MAXLEN 200005#define PAUSE system("pause")using namespace std;int a[MAXLEN<<2];int n;void bu
hdoj 1166 敌兵布阵 【线段树】 //学习线段树Ing 看的这篇blog :http://www.notonlysuccess.com/index.php/segment-tree-complete/ 稍微改了一下#include #define LSON(x) x<<1#define RSON(x) x<<1|1#define MAXLEN 50005int sum[MAXLEN<<2];int L, R;voi
poj 2227 The Wedding Juicer 乱搞版:#include #include #include #define W 305#define H 305#define B 1000000001#define STOP system("pause")inline int max(int a, int b){ return a > b ? a : b; }inline int min(int a, int b){ r
黑书 P42 1.3.8 World Final 2002 - G Partition 从网上下的课后习题解答说用floodfill做,但是根本没有思路,根本不知道怎么去floodfill。后来想主要一点就是去掉其中的多余的线段,用递归把图形处理成符合要求的,然后求上确界和下确界就很简单了。处理的过程有很多很多判断,恶心死了,对于‘|’ 分别判断上下两部分,是否符合要求,对于‘_'判断左右中间敲的太快了,把1敲成2了,wa了三次,好纠结
zoj 1610 Count the Colors【线段树】 //纠结了好久,因为中间的一个逻辑错误#include #include #include #define L(x) ((x) << 1)#define R(x) ((x) << 1 | 1)#define Mid(x, y) (((x)+(y)) >> 1)#define MAX 8005#define P(x) printf(x)#define STOP system("p
系统版本太低..OMG....伤到我了 刚才想在qt中使用SendInput函数,一直提示找不到,进入winuser.h中查看发现前边有一个#if,于是就转用msdn上说已经过时的keybd_event了。据说可以在#include前加上#define _WIN32_WINNT 0x0403解决
hdoj 2199 Can you solve this equation?【二分查找】【水】 OMG。。。刚开始用float wa了,改成double就过了#include double f[100*10000+5];int bsearch(int s, int e, double v){ int m = (s + e) / 2; if(m == s || m == e) return (v - f[s]) < (f[e] - v) ? s : e; e
hdoj 1864 最大报销额 【DP】【01背包】【水】 题意理解错了,以为是单个物品不能超过600了#include #include #define N 31bool f[30*1000*100+1];int main(){ int flag, n, m, i, j, q, price, sum, pa, pb, pc; char type; float temp; while(scanf("%f%d", &t
hdoj 3466 Proud Merchants 【DP】【01背包】 因为剩余金额会对状态产生影响,所以应该先处理p-q较小的#include #include #include #define N 501#define M 5001typedef struct _node{ int p, q, v;}node;node s[N];int comp(const void *a, const void *b){ int m = ((node*)
hdoj 3496 Watch The Movie【二维背包】【DP】 /*不优化会超时~,OMG。。。*/#include #include #define N 105#define M 105#define L 1005int max(int a, int b){ return a > b ? a : b; }int f[M][L];int main(){ int t, n, m, l, w, v, ans; int i, j, k;
ubuntu, windows下安装opencv, 以及在qt,vs2010,dev,codeblock中的使用 ubuntu下打开终端,输入 sudo apt-cache search opencv安装sudo apt-get install libcv-dev libcv2.1 libcvaux-dev libcvaux2.1 libhighgui-dev libhighgui2.1 opencv-doc测试代码:#include int main(int argc, char*
ubuntu11.10下自由截图 在windows下一直用的qq截图,在ubuntu下这么搞:系统设置-》键盘-》快捷键-》自定义快捷键-》+-》名称:自由截图, 命令:gnome-screenshot -a ,貌似有一些迟钝。可以在终端中输入gnome-screenshot -?查看帮助,修改成自己喜欢的样子。Gnome-paint和windows下的画图程序类似。http://www.oschina.net/quest
hdoj 2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活【DP-多重背包】【水】 #include #include #define MAX 200int f[MAX], v_max;int _max(int a, int b){ return a > b ? a : b;}void ZeroOnePack(int cost, int weight){ for(int v = v_max; v >= cost; v--) f[v] = _max(f[v], f