2014年1月8日

摘要: #解决的问题假设我们有这样一个问题:给定a[1],a[2],...a[n],定义两个操作modify,sum* modify(a[i], val):a[i]=val* sum(i,j):求a[i]+a[i+1]+...+a[j] 的值现在希望能高效的处理这两个操作。最直接的思路是仅仅保存a[1],a[2],...a[n], 这样每次修改复杂度是O(1),而求和复杂度则是O(n)。 如果我们定义 s... 阅读全文
posted @ 2014-01-08 10:54 bian 阅读(161) 评论(0) 推荐(0) 编辑
摘要: ## 动态规划两种实现方式根据状态转移,保留中间的计算结果,这种求解问题的算法叫做*动态规划(Dynamic Programming,DP)*,通过空间存取中间结果,避免中间结果的多次求解,从而节省程序的运行时间,是动态规划的主要特变。典型的动态规划算法,实现方式有两种*记忆化搜索*自底向上的循环### 记忆化搜索实现方式类似递归,不过在具体求解前先判断是不是已经算过了,如果算过了,直接返回。```cppint ans[M][N];memset(ans, -1, sizeof(ans));int solve(int m,int n){ if(ans[m][n]==-1) { solve(m.. 阅读全文
posted @ 2014-01-08 10:53 bian 阅读(366) 评论(0) 推荐(0) 编辑

2013年5月18日

摘要: copy constructor is called when an object is created while assignment overload is called when an object has been created.For example#include <iostream>using namespace std;class OBJ{public: OBJ(){} OBJ(OBJ &obj2){ cout<<"copy constructor"<<endl; } void operator = (OBJ& 阅读全文
posted @ 2013-05-18 14:53 bian 阅读(186) 评论(0) 推荐(0) 编辑

2013年1月28日

摘要: 1 #include <iostream> 2 #include <cmath> 3 #include <cstdlib> 4 #include <cstdio> 5 using namespace std; 6 #define N 8 7 8 //Check whether s[k] = pos is ok 9 bool is_ok(int s[], int k, int pos)10 {11 for(int i=0; i<k; i++){12 if(pos == s[i] ) return false;13 if(abs(s[i]-po 阅读全文
posted @ 2013-01-28 15:32 bian 阅读(225) 评论(0) 推荐(0) 编辑

2012年12月18日

摘要: Assume we have movie.mkv and movie.sc.ass under some directory mplayer -ass -subcp cp936 movie.mkv -sub movie.sc.assNotes:-ass: Turn on SSA/ASS subtitle rendering. With this option, libass will be used for SSA/ASS external subtitles and Matroska tracks. You may also want to use -embeddedfonts. NOTE. 阅读全文
posted @ 2012-12-18 13:36 bian 阅读(34469) 评论(0) 推荐(0) 编辑

2012年12月6日

摘要: Pearl Crescent Page Saver Basic [https://addons.mozilla.org/zh-CN/firefox/addon/pagesaver/]Right click, select either "save image of visible portation" or "save image of entire page"or just choose from the camera icon in the toolbar 阅读全文
posted @ 2012-12-06 22:33 bian 阅读(193) 评论(0) 推荐(0) 编辑

2012年10月23日

摘要: aurora seems to be a good optionhttp://ishare.iask.sina.com.cn/f/12202827.html 阅读全文
posted @ 2012-10-23 12:42 bian 阅读(147) 评论(0) 推荐(0) 编辑

2012年8月20日

摘要: http://code.activestate.com/recipes/438123-file-tkinter-dialogs/ 阅读全文
posted @ 2012-08-20 16:48 bian 阅读(263) 评论(0) 推荐(0) 编辑

2012年8月13日

摘要: Convert a build in data type(int, tuple, list dict, str) to str is easy. str() can handle thisstr(12) => '12'str([1,2,'One']) => '[1,2,"One"]'str({1:'One', 2:'Two'}) => "{1:'One', 2:'Two'}"...So how to do the conver 阅读全文
posted @ 2012-08-13 14:08 bian 阅读(167) 评论(0) 推荐(0) 编辑

2012年7月29日

摘要: Fedora 17, gnome 3Activities -> Applications -> System tools -> System settings -> Region and Language -> Layouts ->Options -> Ctrl key position ->Swap Ctrl and CapsLock 阅读全文
posted @ 2012-07-29 13:06 bian 阅读(297) 评论(0) 推荐(0) 编辑

导航