Death_Scythe's blog

By Death_Scythe, history, 8 years ago, In English

Hello all! :)

I stumbled upon this problem but I do not know how to solve it.

http://www.spoj.com/problems/ADDLCM/

The sum can be written as

but this doesn't make the problem any easier. I can evaluate the first sum but its not easy to evaluate the second. Please give me some ideas to solve this.

Any help is appreciated. Thanks!

  • Vote: I like it
  • +3
  • Vote: I do not like it

»
8 years ago, # |
  Vote: I like it +4 Vote: I do not like it

This will help blog

  • »
    »
    8 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I already read it but I do not see how to simplify the second sum in terms of totient function.

    • »
      »
      »
      8 years ago, # ^ |
      Rev. 13   Vote: I like it 0 Vote: I do not like it

      We have to basically calculate:

      Now , using the property

      LCM(x, y) = x * y / gcd(x, y)

      The summation changes to :

      (See I have change the limits that is why an extra N on the left side as i=N is trivial) Now writing the summation in reverse order:

       ≠ wline

      Adding the first and this equation you get:

      which can be computed and we can output x.

      • »
        »
        »
        »
        8 years ago, # ^ |
          Vote: I like it +4 Vote: I do not like it

        Please read the problem I am trying to ask. I already know how to evaluate the sum you have mentioned (basically the first sum in OP), I am facing trouble evaluating the second sum, the limits of which do not end at b. Thanks!

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Anyone? I am really stuck on this one for a long time. I feel this can be solved with Mobius inversion but given my inexperience with that, I am not sure how to proceed in that direction.

As before, any help is appreciated. Thanks!

»
8 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

You can transform the sum a bit to a sum of expressions like this:

i.e. a sum of numbers relatively prime to z. As z ≤ 106, it can't have more than 7 prime divisors, and the sum can be calculated quite fast using the inclusion-exclusion principle.