Hi, I'm stuck on this problem, but I'm unable to find a solution which I could understand. Can someone explain it to me

Before contest

Codeforces Round #687 (Div. 1, based on Technocup 2021 Elimination Round 2)

23:55:00

Register now »

Codeforces Round #687 (Div. 1, based on Technocup 2021 Elimination Round 2)

23:55:00

Register now »

*has extra registration

Before contest

Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2)

23:55:01

Register now »

Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2)

23:55:01

Register now »

*has extra registration

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

1 | tourist | 3687 |

2 | ecnerwala | 3600 |

3 | Benq | 3503 |

4 | ksun48 | 3421 |

5 | Um_nik | 3412 |

6 | Radewoosh | 3382 |

7 | maroonrk | 3323 |

8 | Itst | 3239 |

9 | apiadu | 3238 |

10 | ko_osaga | 3232 |

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

1 | Errichto | 205 |

2 | SecondThread | 199 |

3 | Monogon | 195 |

4 | vovuh | 190 |

5 | Um_nik | 186 |

6 | pikmike | 185 |

7 | antontrygubO_o | 184 |

8 | Ashishgup | 181 |

9 | pashka | 169 |

10 | Radewoosh | 167 |

Hi, I'm stuck on this problem, but I'm unable to find a solution which I could understand. Can someone explain it to me

↑

↓

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Nov/28/2020 10:10:01 (g2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

click

uh sorry, but the problem tells us to compute the sum of sum of divisors of i for i = 1 -> n, not the sum of divisors of n only

Then may be Dirichlet's Formula, Though I don't understand it properly. So, can't explain more.

Well, I did google this and I can't come up with a O(sqrt(n)) solution or less

In case you haven't figured out yet

For a divisor d, d can appear floor(n, d) times as divisor of all number 1-n. E.g. n=100, d=2 then 2 can appear 50 times as divisor

We also know that every divisor from (floor(n, d+1)+1, floor(n, d)) can appear d times. E.g. n=100, d=2 then every divisor from (34, 50) can appear 2 times.

Can you see O(sqrt(n)) approach from this?

thanks, I coded it and it worked, turns out it's not that hard ....

Can you tell me why "every divisor from (floor(n, d+1)+1, floor(n, d)) can appear d times" please. Thanks :)

We can see that the sum is equivalent to

It's easy to see that

has only O(sqrt(N)) distinct values, so we can group together ranges that has the same division value and use A.P sum.

In case you're wondering why the sum has only $$$O(\sqrt{n})$$$ distinct values:

There are 2 cases for $$$\left \lfloor{\frac{n}{i}}\right \rfloor$$$.

In total, we have at most $$$2 \cdot \sqrt{n} = O(\sqrt{n})$$$ distinct values.

thanks for helping me out :D

which algo is this ? Can i know ?

Common sense.