摘要: 状态压缩uva12368-Candles 2011 - Dhaka 1 #include<stdio.h> 2 #include<string.h> 3 #include<iostream> 4 #include<string> 5 #include<algorithm> 6 #include<math.h> 7 #include<map> 8 #include<queue> 9 using namespace std;10 #define LL long long 11 #define nMAX 阅读全文
posted @ 2012-03-25 22:02 HaoHua_Lee 阅读(133) 评论(0) 推荐(0) 编辑
摘要: ax+by=gcd(a,b)与ax+by=c 模版 1 LL ext_gcd(LL a,LL b,LL& x,LL& y){ //解 ax+by=gcd(a,b); 2 LL t,ret; 3 if (!b){ 4 x=1,y=0; 5 return a; 6 } 7 ret=ext_gcd(b,a%b,x,y); 8 t=x,x=y,y=t-a/b*y; 9 return ret;10 }11 LL ext(LL a,LL b,LL c){ //解 ax+by=c 12 LL x, y;13 L... 阅读全文
posted @ 2012-03-24 11:03 HaoHua_Lee 阅读(162) 评论(0) 推荐(0) 编辑
摘要: uva294-Divisors求因子个数和 1 #include<iostream> 2 #include<cstring> 3 #include <cstdio> 4 #include<string> 5 #include<queue> 6 #include<vector> 7 #include<map> 8 #include <set> 9 #include<hash_set>10 #include<ctime>11 #include<cmath>12 #in 阅读全文
posted @ 2012-03-23 23:03 HaoHua_Lee 阅读(244) 评论(0) 推荐(0) 编辑
摘要: 前言:多数人在使用Google搜索的过程是非常低效和无谓的,如果你只是输入几个关键词,然后按搜索按钮,你将是那些无法得到Google全部信息的用户,在这篇文章中,Google搜索专家迈克尔.米勒将向您展示如何更智能、更高效地进行Google的系列搜索。 Google是一个非常精密成熟的搜索引擎,但大多数的用户都没有能完全地利用到它的能力。一般人就是在Google的搜索框中输入一两个关键字,然后点击“搜索”按钮,等着Google显示出它第一页的搜索结果。这是一个相当简单模式匹配算法的搜索,不幸的是,通常此时出现的大部分都是并不需要的结果。 其实,还是有更好的方式能够让搜索产生一些更少、更为准.. 阅读全文
posted @ 2012-03-18 17:55 HaoHua_Lee 阅读(160) 评论(0) 推荐(0) 编辑
摘要: uva679-Dropping Balls有K个球从一完整二元树(fully binary tree, FBT)的树根(root)一个一个往下掉。当这个球遇到非终端节点时,可能往左子树跑,也可能往右子树跑,如此直到这颗球到达终端节点(也就是树叶)为止。至于在非终端节点时球该往左或往右的决定乃是由2个值true, false 来控制的。如果这非终端节点的现在的值为false,则球来的时候会往左子树走,但是这个值会变为true。如果这非终端节点的现在的值为true,则球来的时候会往右子树走,但是这个值会变为false。请注意:一开始时所有非终端节点的值均为false。另外,在完整二元树中所有的节点 阅读全文
posted @ 2012-03-14 20:46 HaoHua_Lee 阅读(246) 评论(0) 推荐(0) 编辑
摘要: multisetmap<int,multiset<int>> 可用于二维坐标对应的点(并能记录重点)hdu 4022题目大意:在二维平面上,给一些点。有两个操作:给一个d,把所有x为d的点去掉,或把所有y为d的点去掉,问每次去掉的点。 1 #include<iostream> 2 #include<cstdio> 3 #include<vector> 4 #include<string.h> 5 #include<cmath> 6 #include<queue> 7 #include<set& 阅读全文
posted @ 2012-03-12 16:52 HaoHua_Lee 阅读(170) 评论(0) 推荐(0) 编辑
摘要: kmp 模版传入 主串text,匹配串pat,传出text上数组下标开始为什么时能匹配pat。 如 asdvs sd 传出1。int nxt[MAXN]; //nxt[i] 指下标为i的字符的前面最多nxt[i]个字符与开始的nxt[i]个字符相同 ; int nxt[MAXN];char text[MAXN] ,pat[MAXN];void get_nxt(char *pat,int lenp){ int i = 0, j = -1; nxt[0] = -1; while(i < lenp){ if(j == -1 || pat[i] == pat[j])... 阅读全文
posted @ 2012-03-11 21:06 HaoHua_Lee 阅读(406) 评论(0) 推荐(1) 编辑
摘要: hdu 1811Rank of Tetris注意一些特殊情况View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<vector> 4 #include<cstring> 5 #include<cmath> 6 #include<queue> 7 #include<cstdlib> 8 #include<algorithm> 9 using namespace std;10 const int MAX=110000;11 const 阅读全文
posted @ 2012-03-10 14:03 HaoHua_Lee 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 最长公共子序列:模版:int dp[MAX][MAX],n; int maxlen(int x[],int y[]){ memset(dp,0,sizeof(dp)); for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ dp[i][j]=max(dp[i-1][j],dp[i][j-1]); if(x[i]==y[j]){ dp[i][j]=max(dp[i-1][j-1]+1,dp[i][j]); } } } ... 阅读全文
posted @ 2012-03-04 13:31 HaoHua_Lee 阅读(259) 评论(0) 推荐(1) 编辑
摘要: (本文假设读者已经有以下知识:最短路径的基本性 质、Bellman-Ford算法。) 比如有这样一组不等式: X1 - X2 <= 0 X1 - X5 <= -1 X2 - X5 <= 1 X3 - X1 <= 5 X4 - X1 <= 4 X4 - X3 <= -1 X5 - X3 <= -3 X5 - X4 <= -3不等式组(1) 全都是两个未知数的差小于等于某个常数(大于等于也可以,因为左右乘 以-1就可以化成小于等于)。这样的不等式组就称作差分约束系统。 这个不等式组要么无解,要么就有无数组解。因为如果有一组解{X1, X2, ..., 阅读全文
posted @ 2012-03-03 19:49 HaoHua_Lee 阅读(205) 评论(0) 推荐(0) 编辑