Files
python/TangDou/AcWing/BIT/SZSZ_Prepare_0.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

26 lines
557 B
C++

#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;
}