poj 2352 Stars (树状数组 + 1)
2012-09-07 21:25
573 查看
/* Subject: 树状数组 Author : a_clay Created Date : 2012-02-02 Sample : poj 2352 Stars */ #include <iostream> #include <cstring> #include <vector> #include <cstdlib> #include <queue> #include <algorithm> #define Bug cout << "here\n"; using namespace std; const int N = 15005; const int M = 32005; int B[M]; int cnt ; int n, T, k; int lowbit(int x) { return x & (-x); } void add(int i, int x) { while(i <= M) { // 注意, 不是 n, 是 M B[i] += x; i = i + lowbit(i); } } //得到 Bn long long getsum(int i) { long long sum = 0; while(i > 0) { sum += B[i]; i = i - lowbit(i); } return sum; } int main() { int x, y, i; memset(cnt, 0, sizeof(cnt)); memset(B, 0, sizeof(B)); scanf("%d", &n); for(i = 0; i < n; i++) { scanf("%d%d", &x, &y); cnt[getsum(++x)]++; add(x, 1); } for(i = 0; i < n; i++) { cout << cnt[i] << endl; } system("pause"); return 0; }
相关文章推荐
- POJ2352 Stars(树状数组 or SplayTree)
- 【树状数组】POJ 2352 Stars
- [树状数组]POJ 2352 Stars
- POJ 2352 Stars (树状数组)
- POJ 2352 HDU1541 Stars(树状数组)
- POJ2352 Stars(树状数组)
- poj 2352 && hdu 1541 Stars (树状数组)
- POJ 2352 Stars (树状数组)
- POJ 2352 Stars(简单树状数组)
- POJ 2352 && HDU 1541 Stars (树状数组)
- POJ 2352 && HDU 1541 Stars (树状数组)
- (模板题)poj 2352 Stars(树状数组)
- 树状数组 POJ 2352 HDU 1541 Stars
- poj 2352 stars(树状数组)
- POJ-2352 Stars (树状数组,离散,排序)
- POJ 2352 Stars 【树状数组】
- poj 2352 Stars(树状数组基础)
- poj 2352 Stars (树状数组)
- POJ 2352 Stars (树状数组)
- poj 2352 Stars(树状数组)