this_ability's blog

By this_ability, history, 7 weeks ago, In English

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 - Баш и сложная математическая головоломка My submission is Submission link 300235362 Thanks in advance.

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

»
7 weeks ago, # |
  Vote: I like it +3 Vote: I do not like it

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