star

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.
Input
Output
Sample Input
5
1 1
5 1
7 1
3 3
5 5
Sample Output
1
2
1
1
0
- #include"stdio.h"
- #include"string.h"
- int c[32005];
- int a[32005];
- int n;
- int lowbit(int x)
- {
- return x&(-x);
- }
- void updata(int x,int d)
- {
- while(x<=32005)
- {
- c[x]+=d;
- x+=lowbit(x);
- }
- }
- long long int getsum(int x)
- {
- long long int res=0;
- while(x>0)
- {
- res+=c[x];
- x-=lowbit(x);
- }
- return res;
- }
- int main()
- {
- int i,x,y;
- scanf("%d",&n);
- memset(c,0,sizeof(c));
- memset(a,0,sizeof(a));
- for(i=1;i<=n;i++)
- {
- scanf("%d%d",&x,&y);
- x++;//0<=x,y<=
- a[getsum(x)]++;//点已经排好序,记录在X前面的星星 记录同等级的级数
- updata(x,1);//记录个数,只要X<=当前点的横坐标
- }
- for(i=0;i<n;i++)
- printf("%d\n",a[i]);
- }
star的更多相关文章
- 【Star CCM+实例】开发一个简单的计算流程.md
流程开发在CAE过程中处于非常重要的地位. 主要的作用可能包括: 将一些经过验证的模型隐藏在流程中,提高仿真的可靠性 将流程封装成更友好的界面,降低软件的学习周期 流程开发实际上需要做非常多的工作,尤 ...
- github中的watch、star、fork的作用
[转自:http://www.jianshu.com/p/6c366b53ea41] 在每个 github 项目的右上角,都有三个按钮,分别是 watch.star.fork,但是有些刚开始使用 gi ...
- [deviceone开发]-Star分享的几个示例
一.简介 这个是star早期分享的几个示例,都非常实用,包括弹出的菜单,模拟支付密码输入等.初学者推荐.也可以直接使用.二.效果图 三.相关下载 https://github.com/do-proje ...
- 时隔一年再读到the star
The Star Arthur C. Clarke It is three thousand light-years to the Vatican. Once, I believed that spa ...
- Github上的Watch和 Star的区别
Github 推出了新的 Notification 系统,更改了原有的 Watch 机制,为代码库增加了 Star 操作.Notification 将接收 Watching 代码库的动态,包括:* I ...
- 纯css3 Star
<style><!--* { box-sizing: border-box; padding: 0px; margin: 0px; } body, html { height: 10 ...
- Got the Best Employee of the year 2015 Star Award
Got "The Best Employee of the year 2015 Star Award" from the company, thanks to all that h ...
- star ccm+ 11.02安装
STAR CCM+是CD-Adapco公司的主打软件,其安装方式较为简单,这里以图文方式详细描述STAR CCM+11.02安装过程. 1 安装准备工作2 正式安装3 软件破解4 软件测试 1 安装准 ...
- System.Diagnostics.Process.Star的用法
System.Diagnostics.Process.Start(); 能做什么呢?它主要有以下几个功能: 1.打开某个链接网址(弹窗). 2.定位打开某个文件目录. 3.打开系统特殊文件夹,如“控制 ...
- ACM: FZU 2110 Star - 数学几何 - 水题
FZU 2110 Star Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Pr ...
随机推荐
- 第二百二十八天 how can I 坚持
hibernate 还有好多不会搞啊,本来很简单的东西,没用过就不会. 今天... 只是感觉很累,昨天爬山爬的,不知道该写点啥了,买的羽绒服到了,还行吧,凑合穿吧. 睡觉了.今天貌似又发脾气了.哎.. ...
- Supports BorlandIDEServices
Delphi: procedure SetKeystrokeDebugging(Debugging: Boolean); var Dialog: IOTAKeyboardDiagnostics beg ...
- WebBrowser的各种使用方法(未完待续)(XE8+WIN7)
相关资料: 占时想不起来了,有时间我补上吧. 程序下载: http://download.csdn.net/detail/zhujianqiangqq/9666390 实例代码: unit Unit1 ...
- 用LinkedHashMap实现LRU算法
(在学习操作系统时,要做一份有关LRU和clock算法的实验报告,很多同学都应该是通过数组去实现LRU,可能是对堆栈的使用和链表的使用不是很熟悉吧,在网上查资料时看到了LinkedHashMap,于是 ...
- Connecting Physics Bodies
[Connecting Physics Bodies] The kinds of joints you can create in Sprite Kit. You add or remove join ...
- C++11lambda表达式
[C++11lambda表达式] mutable 修饰符,用于修改[]中以值传递的变量,无mutable修饰符的话则不行. 使用示例: #include <vector> #include ...
- Win7 SP1语言包微软官方下载地址及使用方法 2
情形一:如果您的系统版本是企业版.旗舰版,可以在Windows update中检测语言包按照提示下载安装即可.如果觉得Windows update不方便的话,可以在本文第二部分中下载所需的语言包,下载 ...
- redis缓存数据表
直观上看,数据库中的数据都是按表存储的:更微观地看,这些表都是按行存储的.每执行一 次select查询,数据库都会返回一个结果集,这个结果集由若干行组成.所以,一个自然而然 的想法就是在Redis中找 ...
- Gym 101064 D Black Hills golden jewels (二分)
题目链接:http://codeforces.com/gym/101064/problem/D 问你两个数组合相加的第k大数是多少. 先sort数组,二分答案,然后判断其正确性(判断过程是枚举每个数然 ...
- POJ 3659 Cell Phone Network (树dp)
题目链接:http://poj.org/problem?id=3659 给你一个树形图,一个点可以覆盖他周围连接的点,让你用最少的点覆盖所有的点. dp[i][0]表示用i点来覆盖,dp[i][1]表 ...