ZOJ 3940 Modulo Query(YY+二分)】的更多相关文章

Modulo Query Time Limit: 2 Seconds      Memory Limit: 65536 KB One day, Peter came across a function which looks like: F(1, X) = X mod A1. F(i, X) = F(i - 1, X) mod Ai, 2 ≤ i ≤ N. Where A is an integer array of length N, X is a non-negative integer n…
0--M对某个数字取模,相当于把0--M区间进行切割,每次暴力切割一下.结果的算的时候二分一下即可... 看了官方题解才会... #include<cstdio> #include<cstring> #include<queue> using namespace std; +; ; int T,m,sz; struct X { int x; long long y; bool operator<(const X&a)const { return x <…
题目链接  2016 ZJCPC Problem E 考虑一个开区间$[0, x)$对$a_{i}$取模的过程. $[0, x)$中小于$a_{i}$的部分不变,大于等于$a_{i}$的部分被切下来变成了$[0, x$ $mod$ $a_{i})$. 现在考虑开区间$[0, m+1)$,依次对$a_{1}, a_{2}, ..., a_{n}$取模. 考虑到一个数对$10^{5}$个数逐次取模,有效的取模至多$logm$次,那么同理, 这个区间最多分裂出$nlogm$个区间,这个过程用map实现…
Prime Query Time Limit: 1 Second      Memory Limit: 196608 KB You are given a simple task. Given a sequence A[i] with N numbers. You have to perform Q operations on the given sequence. Here are the operations: A v l, add the value v to element with i…
Prime Query Time Limit: 1 Second      Memory Limit: 196608 KB You are given a simple task. Given a sequence A[i] with N numbers. You have to perform Q operations on the given sequence. Here are the operations: A v l, add the value v to element with i…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4062 题意: 现在在一条 $x$ 轴上玩植物大战僵尸,有 $n$ 个植物,编号为 $1 \sim n$,第 $i$ 个植物的位置在坐标 $i$,成长值为 $a_i$,初始防御值为 $d_i$. 现在有一辆小车从坐标 $0$ 出发,每次浇水操作必须是先走 $1$ 单位长度,然后再进行浇水,植物被浇一次水,防御值 $d_i+=a_i$. 现在知道,小车最多进行 $m…
Plants vs. Zombies Time Limit: 2 Seconds      Memory Limit: 65536 KB BaoBao and DreamGrid are playing the game Plants vs. Zombies. In the game, DreamGrid grows plants to defend his garden against BaoBao's zombies. Plants vs. Zombies(?) (Image from pi…
题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2361 来源:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26760#problem/B Beloved Sons Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Once upon a time there liv…
Prime Query Time Limit: 1 Second      Memory Limit: 196608 KB You are given a simple task. Given a sequence A[i] with N numbers. You have to perform Q operations on the given sequence. Here are the operations: A v l, add the value v to element with i…
动态区间询问kth,单点修改. 区间用线段树分解,线段树上每条线段存一颗平衡树. 不能直接得到kth,但是利用val和比val小的个数之间的单调性,二分值.log^3N. 修改则是一次logN*logN. 总体是Nlog^2N+Mlog^3N. 一个值可以对应多个名次.每次查询严格小于val的个数. 把之前的Treap的值域加了一个vs表示值的出现次数,这样就可以支持重复的val了,并可以统计出值出现次数. 这样每个值的名次就变成一个区间了. 复杂度更低的做法:树状数组套主席树,还不太会. #i…