'commit'
This commit is contained in:
26
TangDou/AcWing/BIT/SZSZ_Prepare_0.cpp
Normal file
26
TangDou/AcWing/BIT/SZSZ_Prepare_0.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
const int N = 110;
|
||||
int n;
|
||||
//树状数组模板
|
||||
int tr[N];
|
||||
#define lowbit(x) (x & -x)
|
||||
void add(int x, int c) {
|
||||
for (int i = x; i <= n; i += lowbit(i)) tr[i] += c;
|
||||
}
|
||||
int sum(int x) {
|
||||
int res = 0;
|
||||
for (int i = x; i; i -= lowbit(i)) res += tr[i];
|
||||
return res;
|
||||
}
|
||||
int main() {
|
||||
n = 8;
|
||||
for (int i = 1; i <= n; i++) add(i, 1);
|
||||
|
||||
for (int i = 1; i <= 8; i++) cout << tr[i] << endl;
|
||||
|
||||
// for (int i = 1; i <= 8; i++)
|
||||
// cout << sum(i) << endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user