上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 24 下一页
摘要: /*还是老老实实的先用线段树来解决吧区间和,区间更新对于区间更新,这个如果更新到底的话,比较耗时,所以我新增了递增量。这样如果区间刚好和更新区域一样的话,就不要往下去了。只保存递增量但是区间和的时候,就要有点变换了。出了拿出区间的和(已保存),还要计算从父节点过来的递增量。这个递增量和孩子节点的递增量是可以相加的这样,区间和的复杂度没有增加,区间更新的复杂度小了点。这样的时间大概是 1500ms*/// include file#include <cstdio>#include <cstdlib>#include <cstring>#include < 阅读全文
posted @ 2011-04-14 21:11 AC2012 阅读(231) 评论(0) 推荐(0) 编辑
摘要: /*树状数组,二分找第K个*/// include file#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <cctype>#include <ctime>#include <iostream>#include <sstream>#include <fstream>#include <iomanip>#include <bitset>#include < 阅读全文
posted @ 2011-04-14 16:14 AC2012 阅读(230) 评论(0) 推荐(0) 编辑
摘要: /*换一种更高效的方法。之前的方法之所以超时,是因为找第K大数的方法很慢。查找第K大,可以利用树状数组和二分的方法,二分答案,然后树状数组高效回答这个答案是否靠谱 很多细节需要注意,WA,TLE N多*/// include file#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <cctype>#include <ctime>#include <iostream>#include <sstream 阅读全文
posted @ 2011-04-14 13:52 AC2012 阅读(175) 评论(0) 推荐(0) 编辑
摘要: /*线段树需要用到求一个数的约数个数,这个需要打个表吧此处的表,是借用了别人。因为我只是想学习下线段树,偷懒了下 这线段树,其实也没什么特别的,重要的是如何构造线段树的保存的值。就想网络流,二分匹配的算法似的本身没什么特别的,但是构图很重要,比算法本身重要*/// include file#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <cctype>#include <ctime>#include <iost 阅读全文
posted @ 2011-04-13 23:40 AC2012 阅读(206) 评论(0) 推荐(0) 编辑
摘要: /*起初还想用DP来着,好像是不大行现在有了树状数组,二维的一下子就解决了,方便,快捷 */// include file#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <cctype>#include <ctime>#include <iostream>#include <sstream>#include <fstream>#include <iomanip>#inc 阅读全文
posted @ 2011-04-13 16:34 AC2012 阅读(149) 评论(0) 推荐(0) 编辑
摘要: /*一维树状数组的简单二维扩展 */// include file#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <cctype>#include <ctime>#include <iostream>#include <sstream>#include <fstream>#include <iomanip>#include <bitset>#include 阅读全文
posted @ 2011-04-13 16:14 AC2012 阅读(185) 评论(0) 推荐(0) 编辑
摘要: /*二维的树状数组这树状解法出了是二维的以外,还有个巧妙的应用。常规的BIT是用+lowbit计算更新,-lowbit计算和不过这只是一种现象,+lowbit和-lowbit还可以做别的事情,只要发散思维。 这个题目的特殊性是,更新是一个区间,查找是一个点的值每个点可以被操作多次,那么最后要找出这个点的值是多少。该怎么做呢?如果更新用-lowbit实现,会有什么效果? 效果是比该点小的所有的Bit值都增加了1,这就相当于对区间进行更新了。查找用+lowbit实现,会有什么效果?效果是比该店大的所有的Bit值都是对该点所做的操作,把他们全部加起来,就是总共操作的次数,然后对2取模,就是最后要的结 阅读全文
posted @ 2011-04-13 15:46 AC2012 阅读(511) 评论(0) 推荐(0) 编辑
摘要: // include file#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <cctype>#include <ctime>#include <iostream>#include <sstream>#include <fstream>#include <iomanip>#include <bitset>#include <algorithm># 阅读全文
posted @ 2011-04-13 11:34 AC2012 阅读(143) 评论(0) 推荐(0) 编辑
摘要: /*答案就在一念之间*/// include file#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <cctype>#include <ctime>#include <iostream>#include <sstream>#include <fstream>#include <iomanip>#include <bitset>#include <al 阅读全文
posted @ 2011-04-13 10:31 AC2012 阅读(231) 评论(0) 推荐(0) 编辑
摘要: /*树状数组,线段树,合并排序*/// include file#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <cctype>#include <ctime>#include <iostream>#include <sstream>#include <fstream>#include <iomanip>#include <bitset>#include & 阅读全文
posted @ 2011-04-12 23:47 AC2012 阅读(119) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 24 下一页