hdu 1556 Color the ball(前缀和)
来源:互联网 发布:admin.php编程语言 编辑:程序博客网 时间:2024/05/16 10:13
Color the ball
N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?
/* * mai.cpp * * Created on: 2015年9月15日 * Author: chen */#include<stdio.h>#include<iostream>#include<string>#include<string.h>#include<algorithm>#include<vector>#include<time.h>#include<queue>#include<stack>#include<iterator>#include<math.h>#include<stdlib.h>#include<limits.h>#include<memory.h>//#define ONLINE_JUDGE#define eps 1e-8#define INF 0x7fffffff#define FOR(i,a) for((i)=0;i<(a);(i)++) //[i,a);#define MEM(a) (memset((a),0,sizeof(a)))#define sfs(a) scanf("%s",a)#define sf(a) scanf("%d",&a)#define sfI(a) scanf("%I64d",&a)#define pf(a) printf("%d\n",a)#define pfI(a) printf("%I64d\n",a)#define pfs(a) printf("%s\n",a)#define sfd(a,b) scanf("%d%d",&a,&b)#define sft(a,b,c)scanf("%d%d%d",&a,&b,&c)#define for1(i,a,b) for(int i=(a);i<b;i++)#define for2(i,a,b) for(int i=(a);i<=b;i++)#define for3(i,a,b)for(int i=(b);i>=a;i--)#define MEM1(a) memset(a,0,sizeof(a))#define MEM2(a) memset(a,-1,sizeof(a))#define LL __int64const double PI = acos(-1.0);template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }template<class T> inline T Min(T a, T b) { return a < b ? a : b; }template<class T> inline T Max(T a, T b) { return a > b ? a : b; }using namespace std;template<class T>T Mint(T a, T b, T c) { if (a>b) { if (c>b) return b; return c; } if (c>a) return a; return c;}template<class T>T Maxt(T a, T b, T c) { if (a>b) { if (c>a) return c; return a; } else if (c > b) return c; return b;}const int maxn=100010;int T,n,m;int f[maxn];int main(){#ifndef ONLINE_JUDGE freopen("test.in","r",stdin); freopen("test.out","w",stdout);#endif while(~sf(n)&&n){ int a,b; MEM1(f); for1(i,0,n){ sfd(a,b); f[a]++; f[b+1]--; } int m=0; for2(i,1,n){ m+=f[i]; printf("%d%c",m,i==n?'\n':' '); } } return 0;}
0 0
- hdu 1556 Color the ball(前缀和)
- HDU 1556 Color the ball【树状数组||前缀和】
- HDU1556 color the ball(前缀和)
- hdu(1556)Color the ball
- HDU 1556 Color the ball (模拟)
- HDU 1556 Color the ball(BIT)
- hdu 1556 color the ball
- hdu 1556Color the ball
- HDU 1556 - Color the ball
- Hdu 1556 Color the ball
- hdu 1556 Color the ball
- hdu 1556 Color the ball
- hdu 1556 Color the ball
- hdu 1556 Color the ball
- hdu 1556 Color the ball
- hdu 1556 Color the ball
- HDU 1556 Color the ball
- HDU 1556 Color the ball
- 调用 BitmapFactory.decodeByteArray 函数返回 null 值
- AngularJs权威教程 读书笔记
- Android 一张图看明白Hander的运行机制
- 深入理解HTTP Session
- strlen和sizeof 简析
- hdu 1556 Color the ball(前缀和)
- C语言指针5分钟教程
- [TwistedFate]高级内存管理 多态
- SlidingMenu 在Android Studio使用详解
- (转)CoCreateInstanceEx使用详解
- 封装获取上月、本月、近15天、近30天方法
- CvArr、Mat、CvMat、IplImage、BYTE转换(总结而来)
- java 光线追踪
- KMP算法详解