摘要: 经典dp问题:求两个字符串的LCS(最长公共子序列)。 阅读全文
posted @ 2015-07-14 10:18 hxy_has_been_used 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 容易想到:对于每个i,求出最大的第一个子段在区间[0,i]内和最大的第二个子段在区间[i+1,n-1]内再相加即可。 对于第一个子段的求法: 令p[i]表示以i结尾的子段的最大连续子段和,则显然有: p[i] = max( a[i], a[i] + p[i - 1] ); 求完以后再: p[i] = 阅读全文
posted @ 2015-07-14 09:53 hxy_has_been_used 阅读(268) 评论(0) 推荐(0) 编辑
摘要: 先上委托的例子: 1 using System; 2 3 delegate int myDelegateHandler(int a, int b); 4 5 public class A 6 { 7 //静态方法 8 public static int M1(int a, int... 阅读全文
posted @ 2015-05-18 18:32 hxy_has_been_used 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 学过Linux或者Java的应该都知道线程的概念,C#也支持通过多个线程来并行执行任务。任何一个C#的程序会开始于一个单线程(由CLR和OS自动创建的主线程)。下面是简单的例子: 1 using System; 2 using System.Threading; 3 4 namespace ... 阅读全文
posted @ 2015-05-11 12:53 hxy_has_been_used 阅读(192) 评论(0) 推荐(0) 编辑
摘要: WPF简介:全称:Windows Presentation Foundation,看名字就知道WPF主要是用来做UI的,并且功能非常强大,堪比flash。百度百科里是这样说的:WPF(Windows Presentation Foundation)是微软推出的基于Windows Vista的用户界面... 阅读全文
posted @ 2015-05-04 21:34 hxy_has_been_used 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 要点:一个汉字占两个字节,且这两个字节对应的整数值为负,即符号位是1 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 10001; 7 char str[N]; 8 9 int main (... 阅读全文
posted @ 2015-05-03 18:41 hxy_has_been_used 阅读(244) 评论(0) 推荐(0) 编辑
摘要: 这数据量和这时限,很显然暴力是最好的解法,预处理前缀和,n方复杂度秒过。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 1001; 7 int a[N][N]; 8 int m, n, x,... 阅读全文
posted @ 2015-05-02 20:05 hxy_has_been_used 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 方法1:块状链表PS:块状链表太强大了,也可以实现和线段树一样的lazy操作来提高效率。每个块维护自己块的信息,这个题中可以考虑每个块维护一个map来记录每个颜色在区间中出现了多少次。 1 #include 2 #include 3 #include 4 #include 5 #i... 阅读全文
posted @ 2015-05-02 16:12 hxy_has_been_used 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 经典的线段树题目,也可以用块链来做。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 typedef __int64 ll; 8 const ll M = 400; 9 ll b... 阅读全文
posted @ 2015-05-02 10:10 hxy_has_been_used 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 经典的线段树题目,也可以用块状链表做。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int N = 200000; 8 const int M = 800; 9 ... 阅读全文
posted @ 2015-05-01 19:27 hxy_has_been_used 阅读(190) 评论(0) 推荐(0) 编辑