码迷,mamicode.com
首页 >  
搜索关键字:lowbit    ( 485个结果
[CF792D] Paths in a Complete Binary Tree (规律, 位运算, lowbit)
题目链接:http://codeforces.com/problemset/problem/792/D 画出树,找找规律,画图就好了。不算麻烦。 往下走的时候特判是不是叶子,往上走的时候特判是不是根。其余时候按照规律转移就是。 感觉可以推广到建树上,可以缩小常数是极好的。 ...
分类:其他好文   时间:2017-08-18 21:26:49    阅读次数:199
树状数组模板
#include #include #include #include using namespace std; int lowbit(int i) { return i&-1; } void add(int i,int value) { while(i0) { sum+=c[i]; i-=lowb... ...
分类:编程语言   时间:2017-08-13 14:20:24    阅读次数:151
HDU 6113 度度熊的01世界 【DFS】(2017"百度之星"程序设计大赛 - 初赛(A))
度度熊的01世界 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1117 Accepted Submission(s): 400 Problem ...
分类:其他好文   时间:2017-08-13 12:17:40    阅读次数:243
(POJ 1990)Mowfest(确定不再来一发树状数组么?)
MooFest Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8177 Accepted: 3691 Description Every year, Farmer John's N (1 <= N <= 20,000) cows ...
分类:编程语言   时间:2017-08-09 14:27:21    阅读次数:220
bzoj1106
模拟+树状数组 先开始以为是先删距离最小的,这样可以减小上下的距离,然后觉得很难写,看码长很短,就看了题解,结果很奥妙 我们只考虑两种元素,就是如果像-a-b-a-b-这样的肯定得交换,如果像-a-b-b-a-或-a-a-b-b-这样的就不用交换,于是我们对于每个元素考虑其他元素,也就是统计两个相同 ...
分类:其他好文   时间:2017-08-08 16:55:59    阅读次数:159
POJ 1002 487-3279
487-3279 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 294197 Accepted: 52694 Description Businesses like to have memorable telephone num ...
分类:其他好文   时间:2017-08-07 17:41:08    阅读次数:209
HDU 1996 汉诺塔VI
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1996 n个盘子的汉诺塔问题的最少移动次数是2^n-1,即在移动过程中会产生2^n个系列。由于 发生错移产生的系列就增加了,这种错误是放错了柱子,并不会把大盘放到小盘上,即各柱 子从下往上的大小仍保持如下 ...
分类:其他好文   时间:2017-08-07 11:51:46    阅读次数:182
hdu 1394 Minimum Inversion Number - 树状数组
The inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i < j and ai > aj. For a given sequence o ...
分类:编程语言   时间:2017-08-05 18:50:31    阅读次数:244
树状数组
1 int c[MAXN]; 2 int n; 3 4 int lowbit(int x){ 5 return (x&(-x)); 6 } 7 8 void updata(int x,int v){ 9 while(x 0){//从大到小求和 18 sum += c[x]; 19 x -= lowb... ...
分类:编程语言   时间:2017-08-04 11:00:49    阅读次数:141
主席树
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <cstdlib> #define maxn 10000 ...
分类:其他好文   时间:2017-08-03 23:06:55    阅读次数:491
485条   上一页 1 ... 25 26 27 28 29 ... 49 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!