101466K - Random Numbers Can any one give me a hint? Thank you!
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
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.