CF679E Bear and Bad Powers of 42】的更多相关文章

一段时间不写线段树标记,有些生疏了 codeforces 679e Bear and Bad Powers of 42 - CHADLZX - 博客园 关键点是:42的次幂,在long long范围内只有11个 考虑暴力修改 记录每个点距离下一个42次幂的距离,一般是负数 再记录每个点的等级,则有num=mi[lev+1]+val 特别地,当val=0的时候,num就是第lev个42的次幂 假如只有3操作,区间加,如果当前区间最大值大于等于0, 那么暴力下去升级:如果区间最大值大于等于0,就接着…
传送门 今天子帧的一套模拟题的T3. 考试的时候其实已经想到了正解了,但是一些地方没有想清楚,就没敢写,只打了个暴力. 首先考虑用线段树维护区间信息. 先把每个值拆成两个信息,一是距离他最近的且大于他的$42$的整次幂,而是到距离他最近的且大于他的$42$的整次幂的距离. 操作1和操作2不需要细说. 对于操作3,每次加入一个数后check整棵线段树的Min,如果出现负数就逐个升级.如果出现了0就再次增加,直到不出现0为止. 因为每个数最多升级$logN$次,所以时间上是没有问题的. 另一个小细节…
传送门:http://codeforces.com/contest/679/problem/E 题目意思很清晰,给你一个序列,要求你完成以下三个操作: 1.输出A[i] 2.将[a,b]区间的所有数字变成c 3.将[a,b]区间的每个数加上c,若此时区间内有42的整次幂(1,42,422,423,424...),则一直进行此操作,直到区间内没有这类数: 正解: 线段树拓展题目: 先不考虑操作2,只考虑操作3: 我可以给每个数字设置一个等级,即处在(1,42)的数1级,(42,422)的数2级,以…
http://codeforces.com/contest/121/problem/E 话说这题貌似暴力可A啊... 正解是想出来了,结果重构代码,调了不知道多久才A 错误记录: 1.线段树搞混num(节点编号)和l(区间端点) 2.之前的dfs没有分离,写的非常混乱,迫不得已重构代码 #include<cstdio> #include<algorithm> #include<cstring> #include<vector> using namespace…
Codeforces 题目传送门 & 洛谷题目传送门 这个 \(42\) 的条件非常奇怪,不过注意到本题 \(a_i\) 范围的最大值为 \(10^{14}\),而在值域范围内 \(42\) 的幂的个数最多只有 \(13\) 个,故考虑用类似于 seg-beats 的方法解决这道题. 首先不考虑操作 \(2\)(区间赋值操作),我们很容易发现一个性质,那就是我们对一个区间进行区间加的操作,每额外进行一次,都是因为存在某个数 \(a_i\) 达到了 \(42\) 的整数次幂,而我们的 \(a_i\…
Consider all integer combinations ofabfor 2a5 and 2b5: 22=4, 23=8, 24=16, 25=32 32=9, 33=27, 34=81, 35=243 42=16, 43=64, 44=256, 45=1024 52=25, 53=125, 54=625, 55=3125 If they are then placed in numerical order, with any repeats removed, we get the f…
D. Bear and Tower of Cubes 题目连接: http://www.codeforces.com/contest/680/problem/D Description Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many…
题目链接: D. Bear and Tower of Cubes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has inf…
1142 - Summing up Powers (II)    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Shanto is learning how to power up numbers and he found an efficient way to find kth power of a matrix. He was quite happy with his discovery.…