1556专题

HDU 1556 Color the ball (树状数组-- 区间更新,单点求值)

OJ题目 :点这里~~ 与 单点更新,区间求值 稍有不同,需要理解注意。 AC_CODE int n;int num[100002];int lowbit(int x){return x&(-x);}int sum(int x){int ret = 0;while(x > 0){ret += num[x];x -= lowbit(x);}return ret;}void ad

CSU - 1556 Jerry's trouble(快速幂取模)

【题目链接】:click here 【题目大意】:计算x1^m+x2^m+..xn^m(1<=x1<=n)( 1 <= n < 1 000 000, 1 <= m < 1000) 【解题思路】:快速幂取模 代码: solution one: #include<bits/stdc++.h>#define LL long longusing namespace std;const

hdu(1556)Color the ball

第一次用直接更新到节点的方法,结果果断超时。。唉。。 只有用更新区间的方法了;只要图的颜色在这个区间就可以加一, 这样使得增加的值都存在了区间最大的节点上,为了使其下达给下面各个节点,就用到了sum函数。 不过这样感觉还是慢啊,一千多毫秒。。 #include"stdio.h" #include"string.h" struct point {  int x,y,sum,s; }a[400

HDU--1556 -- Color the ball [树状数组] [线段树]

Color the ball   Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5864    Accepted Submission(s): 3122 Problem Description N个气球排成一排,从

hdu 1556 Color the ball(水题)

题目链接:hdu 1556 Color the ball 题目大意:略。 解题思路:用个数组维护即可。 #include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 100000;int N, c[maxn + 5];int main () {while (sc

(HDU 1556)Color the ball 一维树状数组 裸题

Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 19721 Accepted Submission(s): 9815 Problem Description N个气球排成一排,从左到右依次编号为1,2,3…

HDU 1556 Color the ball(树状数组,基础,气球染色问题)

http://acm.split.hdu.edu.cn/showproblem.php?pid=1556 Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 17173    Accep

hdoj 1556 Color the ball 【树状数组】

Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 9769    Accepted Submission(s): 5028 Problem Description

POJ 1556 The Doors 计算几何+ 最短路

计算几何入门 枚举任意两个点,看连成的线段之间是否交于其他线段,如果中间没交与其他线段,表明两个点可通过直线到达 然后将所有的这种都跑出来。 建图求最短路即可 #include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <cst

1556. 千位分隔数

1556. 千位分隔数 C代码: char * thousandSeparator(int n){char* str = (char*)malloc(sizeof(char) * 20);int len = sprintf(str, "%d", n);int len2 = 0;if (len % 3 == 0) {len2 = len+ len / 3 - 1;} else {len2