Color the ball?????????1556???

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Color the ball?????????1556???相关的知识,希望对你有一定的参考价值。

?????????man   1.4   ??????   div   sans   family   turn   san   ring   

Color the ball

Time Limit : 9000/3000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 8   Accepted Submission(s) : 2

Font: Times New Roman | Verdana | Georgia

Font Size: ??? ???

Problem Description

N???????????????????????????????????????????????????1,2,3....N.????????????2?????????a b(a <= b),lele??????????????????????????????"?????????????????????a???????????????b????????????????????????????????????????????????N?????????lele??????????????????I???????????????????????????????????????????????????????????????????????????????????????????????????

Input

?????????????????????????????????????????????N,(N <= 100000).????????????N??????????????????2?????????a b(1 <= a <= b <= N)???


???N = 0??????????????????

Output

??????????????????????????????????????????N???????????????I???????????????I????????????????????????????????????

Sample Input

3
1 1
2 2
3 3
3
1 1
1 2
1 3
0

Sample Output

1 1 1
3 2 1
/*?????????????????????

*/ #include<stdio.h> #include<string.h> int n,tree[100010]; int lowbit(int N) { return N&(-N); } int add(int i,int t)//??????i?????????????????????t. { while(i<=n) { tree[i]+=t; i+=lowbit(i); } } int sum(int m) { int sum=0; while(m>0) { sum+=tree[m]; m-=lowbit(m); } return sum; } int main() { int i,a,b; while(scanf("%d",&n),n) { memset(tree,0,sizeof(tree)); for(i=0;i<n;i++) { scanf("%d %d",&a,&b); add(a,1); //???a????????????????????????1. add(b+1,-1);//???b????????????????????????1. } printf("%d",sum(1)); for(i=2;i<=n;i++) printf(" %d",sum(i)); printf("\n"); } return 0; }



以上是关于Color the ball?????????1556???的主要内容,如果未能解决你的问题,请参考以下文章

HDU 1556 Color the ball

Color the ball?????????1556???

Color the ball

hdu1556 Color the ball

hdu1556-Color the ball

HDU——T 1556 Color the ball