You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
557 B
26 lines
557 B
#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;
|
|
} |