
树状数组
zzuli-dk
这个作者很懒,什么都没留下…
展开
-
树状数组 模板
void uptree(int i,int val) { while (i { tree[i]+=val; i+=i&-i; } } int sum(int i) { int s=0; while (i>0) { s+=tree[i]; i-=i&-i原创 2016-10-07 14:15:12 · 449 阅读 · 0 评论 -
hdu 1116 线段树或树状数组(基础题)
题意: made in china 接下来,直接。。贴 #include #include #include #include #include #include #include using namespace std; const int inf =0x3f3f3f3f; typedef long long LL; const int N = 1005; int a原创 2016-09-19 21:46:01 · 307 阅读 · 0 评论 -
计蒜客 青出于蓝胜于蓝 dfs序+树状
思路:建立dfs序后,利用树状数组(或线段树)先把当前名次所在区间加+1,然后求dfs序区间值的差,即答案。#include <iostream> #include <cmath> #include <cctype> #include <cstring> #include <algorithm> #include <cstdio&...原创 2018-03-16 17:49:45 · 297 阅读 · 0 评论