CF121E Lucky Array】的更多相关文章

题解: 这个题好像暴力+线段树就能过 就是对修改操作暴力,线段树维护查询 为啥呢 因为保证了数$<=1e4$,于是这样复杂度$n*1e4=1e9$ 那么特殊数只有30个 又因为操作是只加不减的,所以每个点最多只有30次修改成特殊数 然后我的做法是建立主席树然后对每个数去二分这30次的位置 注意主席树带区间修改要么标记永久化要么标记下传时重新生成左右儿子 这样是$30*nlog^2{n}$的 (这应该并不会比暴力快) 题解的做法比较优秀 对每个点存下一个比它大的数减它的值 然后我们只需要维护区间最…
E. Lucky Array time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains onl…
E. Lucky Array Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467are not. Petya has an arra…
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya has an array consisting o…
time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky dig…
这个题目的数据感觉不能更水了.从复杂度上计算,肯定有极限数据可以卡掉暴力方法的么. 总之,暴力的做法就是树状数组了,对于区间更新,就挨个更新就是了.当然,判断是否是Lucky Number的话,可以用一个数组标记一下,因为题目中有说数据不会超过10000的.总之就是一个非常不靠谱的方法过了……话说用线段树的区间操作以及延迟标记的话,真心不知道怎么判断加上d之后的Lucky Number的个数,o(╯□╰)o #include <cstdio> #include <cstring>…
10^4以内只由4和7构成的数字只有31种,那么做法就很简单了,求出每个数字与其最接近的幸运数的差值,然后建立线段树,线段树维护区间最小值和最小值个数,如果操作过程中最小值<0,那么就去对差值进行暴力修改,直到区间差值>=0,很明显线段树每个叶子节点不会被修改超过31次,询问操作的话差值=0的数字就是幸运数了.复杂度O(31nlogn) 代码 #include <algorithm> #include <iostream> #include <sstream>…
题目链接 题目大意: 定义只含数字$4,7$的数字为幸运数, 给定序列, 区间加正数, 区间询问多少个幸运数 题解: 对于每一个数, 求出它和第一个比它大的幸运数之差, 则问题转化为区间加,查询$0$的个数 可以维护最大值即最大值的个数, 对于最大值$<=0$直接打标记修改即可 对于最大值$>0$的暴力转移到下一个幸运数, 因为对于每个幸运数来说, 最多有n个元素暴力修改, 可以看成n个点单点更新 所以暴力修改的复杂度$O(Cnlogn)$, $C$为总幸运数个数 总复杂度$O((n+m)lo…
http://codeforces.com/contest/121/problem/E 话说这题貌似暴力可A啊... 正解是想出来了,结果重构代码,调了不知道多久才A 错误记录: 1.线段树搞混num(节点编号)和l(区间端点) 2.之前的dfs没有分离,写的非常混乱,迫不得已重构代码 #include<cstdio> #include<algorithm> #include<cstring> #include<vector> using namespace…
Array转换为List List转换为Array Array转Dictionary Dictionary转Array List转Dictionary Dictionary转List IQueryable,IEnumerable,List相互转换 基本资料, 定义Student类,并添加属性 class Student { public int Id { get; set; } public string Name { get; set; } public string Gender { get…