Блог пользователя hereicomewf

Автор hereicomewf, 10 лет назад, По-английски

I was trying to solve This Problem on Spoj.

The problem is to find the sum of all divisors of i where i=1 to i=N.

We have to solve this in sqrt(n) complexity.

This is the Ac'ed python Code, I couldn't figure out the logic behind this.

Please provide me with some hints..Thanks

  • Проголосовать: нравится
  • +7
  • Проголосовать: не нравится

»
10 лет назад, # |
Rev. 4   Проголосовать: нравится +1 Проголосовать: не нравится

Let .

For each x = 1..m we can find count of numbers divisible by x. It's

For each k = 1..m - 1 we can find all numbers x that divide exactly k numbers. It's range