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

Автор gauravahlawat81, история, 5 лет назад, По-английски

Problem Link [:https://codeforces.com/contest/1249/problem/C2] I read the problem's editorial as well,but wasn't able to wrap my head around the logic. I can understand that we need to represent the number in base 3 and we need to replace any 2 present in the Base 3 representation,also I understand why we need the maximum position of 2, but why should we replace the maximum position of 2 with 0, why not 1 ?

The following part is taken from the editorial:

Let pos0 be the leftmost position of 0 to the right from pos2. We can add 3^pos0 and replace all digits from the position pos0−1 to the position 0 with 0.

Can somebody please help me understand the logic behind it. Thanks in advance.

Полный текст и комментарии »

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

Автор gauravahlawat81, история, 5 лет назад, По-английски

I am getting Memory limit exceeded on my test case #3 , but my algorithm is sure(I guess ?)

Can you please look at my code and tell me what could I possibly be doing wrong.

Thanks in advance.

Code Link: https://codeforces.com/contest/1167/submission/54276749

Полный текст и комментарии »

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