poj 2352.Stars
来源:互联网 发布:tensorflow使用的语言 编辑:程序博客网 时间:2024/04/29 07:47
Stars
#include<stdio.h>const int MAXN=15000;const int MAXX=32000+1;int N, X, Y;int c[MAXN+1];int ans[MAXN];//求整数x最低有效位的值并返回. int LowBit(int x);//求原数组下标从1到ind的各元素的和并返回. int GetSum(int ind);//原数组下标为ind元素增量为diff时,修正相应树状数组. void Modify(int ind, int diff);int main(){int i;while(scanf("%d",&N)!=EOF){for(i=0;i<N;i++){ans[i]=0;}for(i=0;i<=MAXN;i++){c[i]=0;}for(i=0;i<N;i++){scanf("%d%d",&X,&Y);X++;int level=GetSum(X);ans[level]++;Modify(X,1);}//输出结果for(i=0;i<N;i++){printf("%d\n",ans[i]);} }return 0;}int LowBit(int x){return x&(x^(x-1));}int GetSum(int ind){int sum=0;while(ind>0){sum+=c[ind];ind-=LowBit(ind);}return sum;}void Modify(int ind, int diff){while(ind<=MAXN){c[ind]+=diff;ind+=LowBit(ind);}}
- poj 2352.Stars
- poj Stars
- POJ Stars
- Stars POJ
- POJ 2352 STARS
- POJ 2352 Stars
- Poj 2352 Stars
- poj 2352 Stars
- poj 2352 Stars
- poj 2352 Stars
- POJ 2352 Stars
- POJ 2352 Stars
- POJ-2352-Stars
- POJ 2352 Stars
- Poj 2352 Stars 题解
- poj 2352 stars
- POJ 2352 stars
- POJ 2352 - Stars
- oracle 判断是否为数字型(金额型)
- String和StringBuffer的区别
- Asp.Net实现无刷新文件上传并显示进度条(非服务器控件实现)
- S5pv210的 LCD clock 居然只能设那么低的值?why?
- c run-time library(转载)网上看到的 好理解
- poj 2352.Stars
- CentOS下apache服务操作
- hdu 1025 Cstructing Roads
- 如何用构造方法重载构造方法
- keycode对照表
- SQLServer获得所有用户存储过程、根据存储过程名称获得内容、获得数据库对象创建脚本
- 链表的基本操作-单向链表
- Generating SSH Keys
- 检查c#代码内存泄露工具-CLR Profiler工具使用