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

Автор this_ability, история, 20 часов назад, По-английски

hii everyone, I attempted a very good question on Segment tree. Though I have checked my logic with the editorial, I am having errors in its implementation. If anybody could have a look and explain where my code is getting stuck. Problem is 914D. Link to the problem 914D - Bash and a Tough Math Puzzle My submission is Submission link 300235362 Thanks in advance.

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

»
18 часов назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

My submission

My logic was that x is almost gcd iff every number in the range is divisible by x except one

So I just found the 1st index not divisible by x and checked whether it's the only one

(Now that I'm writing this comment, I realised that probably the query made at the left of "idx" isn't needed, the variable "left" should be always -1)

Also here's a test case for which your code fails

5

1 1 10 3 7

1

1 1 2 3

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

    Thanks