Hi!
Did you know is O(nlogn)? (ω(n) is the number of distinct prime divisors of n)
I wonder why! Do you have any mathematical proof for this?
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Hi!
Did you know is O(nlogn)? (ω(n) is the number of distinct prime divisors of n)
I wonder why! Do you have any mathematical proof for this?
Название |
---|
Because 2w(i) ≤ d(i) (d(n) is the number of divisors of n), so this is less than sum of d(i), which is the number of pairs i, j such that j divides i, which is sum of n/j, which is O(nlogn).
At the first look I was totally surprised about this fact, but it sounds easy when you say it like that!
Thanks!
it's nice information, do you know any problems that can be solved using it?
It's one of training tasks for our national OI (INOI):
Consider a n × n forest. For each relatively prime pair (i, j)i, j ≤ n, we plant a tree on position (i, j). The problem is to calculate total sum of pairwise distances between trees!
n ≤ 106, distance((a, b), (c, d)) = |a - c| + |b - d|
Also you can use that fact for this problem.
I don't think that much theoretically about problem, since each number lower than 10^6 has at most 7 distinct prime divisor, we can perform 2^7 * 10^6 :D This problem is much like SGU 370
Yes, but it's always good to know the exact complexity of our solution! (Without considering the limits)
What about lower bound? I can prove just Ω(nloglogn)
Lower bound:
Let Pn be a set of primes not larger than n.
(look here: http://en.wikipedia.org/wiki/Divergence_of_the_sum_of_the_reciprocals_of_the_primes). It follows that average number of different primes divisors is , so since 2x is convex we get that it's at least .