摘要: http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=binaryIndexedTrees翻译版:http://hawstein.com/posts/binary-indexed-trees.html#readcf这篇文章给出了poj上的例题http://duanple.blog.163.com/blog/static/7097176720081131113145832/需求:希望有一个数组a,可以快速计算连续的一段元素的和,如a[i]+a[i+1]+...+a[j],普通的数组对这种查询的时间是和j-i成 阅读全文
posted @ 2013-04-20 21:17 ttang 阅读(170) 评论(0) 推荐(0) 编辑
摘要: const double *cptr;//cptr 是一个指向constdouble 的指针,我们可以重新赋值cptr 使其指向不同的对象但不能修改cptr 指向的对象任何试图将一个非const 对象的指针指向一个常量对象的动作都将引起编译错误对传入某函数的const vector<>&类型,既不可以改变vector中的元素,也不可以对x做赋值(如果不加const,两者都可以),如下例:void f(const vector<int>& x){ //x.clear();//err //x.push_back(2);//err //x[0] = 5;//e 阅读全文
posted @ 2013-04-20 13:21 ttang 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 我希望要一个ArrayList<Entry>,类似C++中的pair,但是Map.Entry是个接口,不能实例化,可以像下面这样写HashMap<Integer, Integer> G = new HashMap<Integer,Integer>();G.put(1, 9); G.put(4, 6); G.put(2, 8);G.put(3, 7); ArrayList<Map.Entry<Integer, Integer>> arrayList = new ArrayList<Map.Entry<Integer, Int 阅读全文
posted @ 2013-04-20 11:27 ttang 阅读(11187) 评论(1) 推荐(0) 编辑