Color the ball HDU - 1556 (非线段树做法)
题意:在1到n的气球中,在不同的区域中涂颜色,问每个气球涂几次。
#include<cstdio>
int num[100010];
int main()
{
int n, x, y;;
while (scanf("%d", &n), n)
{
for (int i = 0; i < n; i++)
{
scanf("%d%d", &x, &y);
num[x] += 1; num[y + 1] -= 1;
}
for (int i = 2; i <= n + 1; i++)
num[i] += num[i - 1];
printf("%d", num[1]); num[1] = 0;
for (int i = 2; i <= n; i++)
{
printf(" %d", num[i]); num[i] = 0;
}
printf("\n");
}
}
Color the ball HDU - 1556 (非线段树做法)的更多相关文章
- Color the ball HDU - 1556 (线段树)
思路:线段树,区间更新 #include<iostream> #include<vector> #include<string> #include<cmath ...
- hdu 1556 Color the ball(非线段树做法)
#include<stdio.h> #include<string.h> ]; int main() { int n,i; int a,b; while(scanf(" ...
- HDU 1556【线段树区间更新】
这篇lazy讲的很棒: https://www.douban.com/note/273509745/ if(tree[rt].l == l && r == tree[rt].r) 这里 ...
- A - Color the ball HDU - 1556 (差分数组+前缀和)
思路等引自博客 https://blog.csdn.net/johnwayne0317/article/details/84928568 对数组a[7]: a[0]=1; = d[0] a[1]=1; ...
- hdu 4031 attack 线段树区间更新
Attack Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)Total Subm ...
- hdu 4288 离线线段树+间隔求和
Coder Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...
- hdu 3016 dp+线段树
Man Down Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...
- HDU 4605 Magic Ball Game(可持续化线段树,树状数组,离散化)
Magic Ball Game Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- Necklace HDU - 3874 (线段树/树状数组 + 离线处理)
Necklace HDU - 3874 Mery has a beautiful necklace. The necklace is made up of N magic balls. Each b ...
随机推荐
- angularjs学习第四天笔记(第一篇:简单的表单验证)
您好,我是一名后端开发工程师,由于工作需要,现在系统的从0开始学习前端js框架之angular,每天把学习的一些心得分享出来,如果有什么说的不对的地方,请多多指正,多多包涵我这个前端菜鸟,欢迎大家的点 ...
- LINQ 小项目【组合查询、分页】
使用 linq 在网页上对用户信息增删改,组合查询,分页显示 using System; using System.Collections.Generic; using System.Linq; us ...
- [转载] C# 调用C++ DLL 的类型转换
//C#调用C++的DLL搜集整理的所有数据类型转换方式,可能会有重复或者多种方案,自己多测试 //c++:HANDLE(void *) ---- c#:System.IntPtr //c++:Byt ...
- SQLServer转PowerDesigner(转载)
将SQLServer中的数据库导入到PowerDesigner 百度得: https://jingyan.baidu.com/article/20095761c98042cb0721b4fc.html ...
- module.exports和exports.md
推荐写法 具体解释可以往后看. 'use strict' let app = { // 注册全局对象 ... } ... // 封装工具箱 exports = module.exports = app ...
- 如何把SVG小图片转换为 html字体图表
自制作的简单字体图表使用案例:查看demo 制作步骤: 1:登录制作工具在线网站 https://icomoon.io/ 2:右上角红色 按钮进入到:https://icomoon.io/app/#/ ...
- git常用命令以及如何与fork别人的仓库保持同步
简单常用命令1.git status查看当前仓库是否有文件改动a:提示Your branch is up-to-date with 'origin/master'.nothing to commit, ...
- HTML meta头部小结
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- windows端ndk 编译.c/cpp文件生成so库示例
- 鸟哥的 Linux 私房菜Shell Scripts篇(二)
参考: http://linux.vbird.org/linux_basic/0340bashshell-scripts.php#script_be http://www.runoob.com/lin ...