Not able to understand the approch

Hii…
I am doing this question…
https://codeforces.com/contest/1451/problem/D
Although i have solved it…
But i want to understand the approch of this man.
This is his code…
https://codeforces.com/contest/1451/submission/99186430
Can you explain what he is doing…

Hey @ashishnnnnn, i have seen the code, just try to dry run you will also understand for test case in which d = 5 & k = 2
What i understood is, as

  • Ashish will always be the first person who will move and utkarsh will always move in second place
  • I can either increase x or y coordinate with utmost k steps, and have to also make sure that if i am at P,Q coordinate then P^2 + Q^2 <= d^2

What he has done in this code he is calculating the left over distance d times by only increasing a unit distance, and whatever iteration gives him the minimum left over distance he stores it max_c variable, know since he was iterating unit distance, so if the max_c is even it will be Utkarsh who have touched the maximum distance staying in d as he goes in second position.
But if max_c is odd it will be Ashish who have touched the maximum distance staying in d as he goes in First position.

Try to dry run it, you will get the intuition automatically.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.