poj 2352 Stars
来源:互联网 发布:北 north plus新域名 编辑:程序博客网 时间:2024/06/06 23:35
题意就是一颗星星的左下方有多少颗星星就是几级;
把每级的星星个数统计好输出就ok;
但不能用二维树状数组,会超内存,,
#include<stdio.h>#include<string.h>#include<iostream>#define maxn 32001using namespace std;int a;int arr[maxn];int low(int x){ return x&(-x);}void update(int x,int val){ for(int i=x;i<=maxn;i+=i&-i) arr[i]+=val;}int getsun(int x){ int temp=0; while(x>0) { temp+=arr[x]; x-=low(x); } return temp;}int main(){ int stars[maxn]; memset(stars,0,sizeof(stars)); scanf("%d",&a); memset(arr,0,sizeof(arr)); for(int i=1;i<=a;i++) { int x,y;; scanf("%d %d",&x,&y); int level=getsun(x+1); stars[level]++; update(x+1,1); } for(int i=0;i<a;i++) printf("%d\n",stars[i]); return 0;}
0 0
- 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
- POJ 2352 Stars
- POJ 2352 Stars
- poj 2352 Stars
- poj 2352 Stars
- Activity正真的活动生存期
- hdu 4379The More The Better
- scp无密码传输
- 黑马程序员---技术博客日记(1)
- 使用集成的ADT bundle来搭建android开发环境
- poj 2352 Stars
- 编程算法 - 堆(heap) 代码(C)
- 黑马程序员-----@property和@synthesize
- windows 2008r2 安装 oracle11gr2 dataguard总结
- 排序算法-冒泡、插入、归并、希尔、快速、选择--代码总结
- const详解
- UVA - 10537 The Toll! Revisited (最短路变形逆推)
- 黑马程序员 C语言的字符数组和字符指针
- 迈向任何地方的第一步,就是下决心不在原地踏步