101466K - Random Numbers Can any one give me a hint? Thank you!
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
4 | adamant | 160 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
8 | Dominater069 | 154 |
8 | nor | 154 |
101466K - Random Numbers Can any one give me a hint? Thank you!
Name |
---|
It can be solved using a segment tree :)
Let’s solve another problem. You are given an array v of length N, where each element is a vector of length k.
Answer two types of queries:
S(i, j): Output vi + vi + 1 + vi + 2 + ... + vj.
M(i, a1, a2, ..., ak): Set vi to (vi1 + a1, vi2 + a2, ..., vik + ak).
This problem can be solved using a binary indexed tree.
Let's reduce the original problem to this using these two observations:
1. Every number Ti in the tree can always be represented as 2a1 × 3a2 × 5a3 × 7a4 × 11a5 × 13a6. Therefore we could store a vector Hi = {a1, a2, a3, a4, a5, a6} in the tree instead of the number itself (Calculating the original number, counting its divisors, and multiplying it with another number using this representation is left as an exercise to the reader).
2. We can reduce subtree queries to range queries on an array using the Euler tour technique.