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?

# | User | Rating |
---|---|---|

1 | MiFaFaOvO | 3520 |

2 | tourist | 3461 |

3 | Um_nik | 3367 |

4 | apiadu | 3351 |

5 | mnbvmar | 3332 |

6 | Benq | 3330 |

7 | LHiC | 3276 |

8 | TLE | 3271 |

9 | Radewoosh | 3251 |

10 | ecnerwala | 3241 |

# | User | Contrib. |
---|---|---|

1 | antontrygubO_o | 189 |

2 | Errichto | 188 |

3 | tourist | 180 |

4 | Radewoosh | 173 |

5 | vovuh | 166 |

6 | pikmike | 165 |

7 | ko_osaga | 162 |

8 | Um_nik | 161 |

9 | rng_58 | 155 |

10 | farmersrice | 153 |

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?

↑

↓

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jan/24/2020 12:54:54 (f2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

Because 2

^{w(i)}≤d(i) (d(n) is the number of divisors ofn), 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×nforest. 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≤ 10^{6},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

P_{n}be a set of primes not larger thann.(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 2

^{x}is convex we get that it's at least .