Maximizing cos(x) + cos(y) + cos(z)
It's been a while since my last blog. Since it's getting closer to IEEEXtreme 12.0 I thought of sharing an algorithmic challenge I tried in one of the past competitive programming contests. I had a thought of penning down some insight into this challenge ever since I solved this. For whatever the reason (maybe for the reason I managed to solve this!) this challenge seems to be quite exciting. First of all, I must say that I am not the author of this challenge and in fact, I can't remember the place I encountered this challenge. (If you happen to know the original author please let me know so that I could give credit to him here) I even created a Hackerrank problem using this. (You can have a try, link ) First, let's take a look at the task. Find the maximum value of $\cos{x} + \cos{y} + \cos{z}$ given that $x + y + z = n$ where $x, y, z, n$ are positive integers. The input constraint was $3 \leq n \leq 3 \times 10^6$ The task description is clear and there is n...