gauravahlawat81's blog

By gauravahlawat81, history, 7 months ago, In English,

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.

Read more »

 
 
 
 
  • Vote: I like it
  • -7
  • Vote: I do not like it

By gauravahlawat81, history, 12 months ago, In English,

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

Read more »

 
 
 
 
  • Vote: I like it
  • -3
  • Vote: I do not like it