# Stars

For example, look at the map shown on the figure above. Level of the star number 5 is equal to 3 (it's formed by three stars with a numbers 1, 2 and 4). And the levels of the stars numbered by 2 and 4 are 1. At this map there are only one star of the level 0, two stars of the level 1, one star of the level 2, and one star of the level 3.

You are to write a program that will count the amounts of the stars of each level on a given map.

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <cmath>
#include <cctype>
#include <cfloat>
#include <climits>
#include <complex>
#include <deque>
#include <list>
#include <set>
#include <utility>
using namespace std;

int cla[32010];
int bit[32010];
pair<int,int> ps[32010];
int n;

{
while(x<=32005){
bit[x]+=1;
x+=x&-x;
}
}

int countn(int x)
{
int an=0;
while(x){
an+=bit[x];
x-=x&-x;
}
return an;
}

int main()
{
//freopen("in.txt","r",stdin);
scanf("%d",&n);
memset(bit,0,sizeof bit);
memset(cla,0,sizeof cla);
int x,y;
for(int i=1;i<=n;i++){
scanf("%d %d",&x,&y);
cla[countn(x+1)-1]++;
}
for(int i=0;i<n;i++){
printf("%d\n",cla[i]);
}
return 0;
}

#### Counting Stars 全中国最准确的翻译！

2014-07-14 00:29:52

#### 【CodeForces 997C】Sky Full of Stars（组合计数）

2018-07-02 20:40:43

#### POJ2352:Stars(树状数组)

2015-06-21 16:44:38

#### Stars(树状数组或线段树)

2015-08-14 16:15:44

#### HDU 1541 star 树状数组

2012-08-04 11:28:06

#### Codeforces 997C Sky Full of Stars

2018-07-03 10:52:59

#### POJ 2352 Stars 解题思路，树状数组

2015-04-28 09:12:42

#### [ACM] hdu 2352 Stars （树状数组）

2014-04-19 20:53:51

#### 【POJ】2482 Stars in Your Window 线段树 + 扫描线

2014-07-13 16:34:36