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

• 本文已收录于以下专栏：

## 视觉测量V-STARS系统

• 2012-09-26 15:41
• 140KB
• 下载

## CMG-STARS使用指南

• 2010-06-19 17:08
• 997KB
• 下载

## D - Stars

Description Astronomers often examine star maps where stars are represented by points on a plane ...

## poj 2352 Stars（树状数组）

StarsDescriptionAstronomers often examine star maps where stars are represented by points on a plane...

## hdu 5533 Dancing Stars on Me

Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/O...

## POJ 2352 stars

Description Astronomers often examine star maps where stars are represented by points on a plane ...

举报原因： 您举报文章：深度学习：神经网络中的前向传播和反向传播算法推导 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)