parveen1981's blog

By parveen1981, history, 3 years ago, In English

In the editorial of this problem, Can someone please tell me how do we arrive at the these equations and what are pos, x, y?

$$$ \begin{cases} pos \equiv x \pmod n \\ pos \equiv y \pmod m \end{cases} $$$

Thanks in advance.

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

»
3 years ago, # |
  Vote: I like it +5 Vote: I do not like it

"x" is the length of days for 1 chandeliers for diff. color

"y" is the length of days for 2 chandeliers for diff. color

ANS is max ( x , y )

Here we do a binary search on lengths "x" and "y" to find positions of differences.

number of valid pos == k

number of "pos" should be equal to "k" ,i.e. days to make Vasya angry

"pos" refers to the POSITION of element to be tested if it is same or not.

pos ≡ x( mod n ) .. >> [ 0 <= pos < n ]

This specifies that the searched element always remain within the search space of array and INDEX OUT OF BOUND is prevented.

same if the case for ## pos ≡ y ( mod m ) .. >> [0 <= pos < m ]

NOW SOLVE THE EQUATIONS TO FIND X and Y , and print max ( X , Y )