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

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

I thought for many days about how do i solve this problem: http://codeforces.com/contest/475/problem/D But it seems to me that I cannot get any better than O(N^2). I think there is a knowledge gap(mathematics). I looked through the editorial too. But I cannot understand. I want to understand the solution. I even looked many of the submissions(using sparse tables, segment trees...). But staring the code doesn't seem to be beneficial(or may be I am too dumb for the problem). So, please help me solve this problem. I just want the idea. Thank you coders!

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

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

Look at authour's solution. At the end of each iteration divisors contain information about all possible intervals [L, R] with (L <= i && R == i) there will be at most 1 + Log(v[i]) different values for gcd on entire interval. divisors[42] is the number of such intervals with gcd value 42.

  • »
    »
    10 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Okay, so at each iteration divisors contains all unique gcd values along with the count of all (a, b) pairs [0, i]. My question is what is the logic. Also, how do I use the information that there will be at most 1 + log(v[i]) unique gcd values for a sequence starting with v[i]. I donot understand that. I would be thankful for any clarification.

»
10 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Have you ever used EZ Collections? http://codeforces.com/blog/entry/14382 It can change everything!

  • »
    »
    10 лет назад, # ^ |
    Rev. 6   Проголосовать: нравится 0 Проголосовать: не нравится

    I don't use java. And I dont think it is related to this post too. Someone please answer my question.