Pagini recente » Diferente pentru blog/post-nou intre reviziile 13 si 7 | Diferente pentru blog/square-root-trick intre reviziile 63 si 64 | Monitorul de evaluare | Autentificare | Diferente pentru blog/square-root-trick intre reviziile 79 si 80
Nu exista diferente intre titluri.
Diferente intre continut:
The update takes constant time, because we have to update the value for A and the value for the corresponding $S$.
!<{margin-right: 20px; auto;display:block;}blog/square-root-trick?image01.png!
p. The code looks like this:
== code(c) |
def update(S, A, i, k, x):
S[i/k] = S[i/k] - A[i] + x
A[i] = x
==
The query is interesting. Slices completely contained in our range are summed up fast. The elements of the first and last slice (partially contained in the queried range) have to be traversed one by one.
!<{margin-right: 20px; auto;display:block;}blog/square-root-trick?image00.png!
p. The code looks like this:
The code looks like this:
== code(c) |
def update(S, A, i, k, x):
S[i/k] = S[i/k] - A[i] + x
A[i] = x
def query(S, A, lo, hi, k):
s = 0
i = lo
Nu exista diferente intre securitate.
Topicul de forum nu a fost schimbat.