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

Автор parveen1981, история, 3 года назад, По-английски

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.

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

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

"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 )