题意: 刚开始有一个空集合.有三种操作: 1.往集合中加入一个集合中不存在的数 x 2.从集合中删除一个已经存在的数 x 3.计算集合的digest sum并输出.       digest sum求法:将集合中所有数从小到大排序,得到a1<a2<...<an. digest sum = sum(ai) where i mod 5 = 3 数据范围: N ( 1 <= N <= 105 ) 1 <= x <= 109. For any "add x&qu…
题意: 给定三种操作 1. add x 向序列中添加x,添加之后序列还保持有序 2. del x  删除序列中值为x的元素 3. sum  求下边模5等于3的元素和 思路: 直接暴力也可以过,就是看暴力写的好不好了.用数组直接暴力可过. 暴力代码: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ; typedef long long ll; int a[max…
题意略. 离线处理,离散化.然后就是简单的线段树了.需要根据mod 5的值来维护.具体看代码了. /* 线段树+离散化+离线处理 */ #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; typedef long long ll; #define N 100010 ll sum[N<<2][5]; int a…
题意: 给n个编号,m个查询每个查询l,r,求下标区间[l,r]中能分成标号连续的组数(一组内的标号是连续的) 分析: 我们认为初始,每个标号为一个组(线段树维护区间组数),从左向右扫序列,当前标号,要考虑和他相邻的标号的位置,若前面位置出现了和它相邻的标号, 则前面位置组数减一(因为可以合并成一组),查询区间离线处理,保证了查询的正确. #include <map> #include <set> #include <list> #include <cmath&g…
http://acm.hdu.edu.cn/showproblem.php?pid=4417 题意:找出给定区间内,有多少个数小于等于给定的数.用线段树维护的话会超时,要用到线段树的离线操作,对询问与数列都进行从小到大的排序,记录下标.从第一个询问开始,遍历数列,满足小于等于就插入到线段树中相应的位置.答案即为当前线段树中有多少个值.转换成了区间和,记录答案,最后一遍输出. 代码如下: #include<stdio.h> #include<algorithm> ; using na…
两个题目都是求区间之内,不重复的数字之和,3333需要离散化处理................. 调试了一下午........说多了都是泪........... #include <iostream> #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <string>…
欢迎參加--每周六晚的BestCoder(有米! ) Necklace Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4003    Accepted Submission(s): 1330 Problem Description Mery has a beautiful necklace. The necklace is made…
Necklace HDU - 3874  Mery has a beautiful necklace. The necklace is made up of N magic balls. Each ball has a beautiful value. The balls with the same beautiful value look the same, so if two or more balls have the same beautiful value, we just count…
题目分析:线段树区间更新+离散化 代码如下: # include<iostream> # include<cstdio> # include<queue> # include<vector> # include<list> # include<map> # include<set> # include<cstdlib> # include<string> # include<cstring&g…
Attack Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 2496    Accepted Submission(s): 788 Problem Description Today is the 10th Annual of “September 11 attacks”, the Al Qaeda is about to attack…