**Problem**:-

**Editorial**:-

scroll down a bit you’ll find the editorial .

And thanks for your time in advance .

**Backstory**:-

## Summary

I’m not sure if that’s healthy for codechef community to seek help regarding a codeforces question here, but I’m kinda desperate so bare me . Only, until recently have I got to know that all the work I’ve put so far is kind waste, so starting new again. I was so far into competitive coding just using the intuitions that I get after reading a question however, recently I found out that it’s not going to take me further without backing up with math…so kinda into approaching question in a math approach. In the above question, after reading editorial, I was convinced with “dfs” approach but not so with the other.

**Doubts**:-

## 1st Doubt

The above question put into equations would be something like,

2^{x} . ( n - y*k ) - y*l = m

where,

n → given number on display

m → a number that we need to attain

y → in this problem, always a “-1”

x, k, l → any non negative integer

and the answer would something be like,

x + k + l

while trying to minimize this total gives us the required answer but this is nowhere close to the actual approach of the editorial help me proceed to the next. From constraints,

0 <= x <= 14

no clue after this. If this is all trash, please help me on how to approach a problem mathematically.

## 2nd Doubt

From the second approach in the editorial and many other submissions, I couldn’t logically or mathematically deduce that inverting the condition like performing operations on variable “m” with “add 1” and “divide by 2” could be more yielding to minimize button clicks than performing operations on variable “n” with “subtract 1” and “multiply by 2”. Need a mathematical proof that either one deduced approach is better/worse than the other.

## 3rd Doubt

I know I ask a lot of questions, kinds first time in discuss_codechef. How do we use Latex for math equations and expressions, seems not working for me…I don’t want to give a eye sore for people trying to help me .

Thank you, for you time…seriously…it helps me grow.