Tuesday problem is really easy. The full problem statement is here. You are given 3 integers . You have to return the closest multiplicity of to . It's guaranteed that which is really good. You have to do it fast, because one test file contains up to testcases.
A pretty straightforward method for solving this is to first compute:
and two multiplicities of :
1. The first one is the greatest number of form which is less or equal , let's call it :
2. The second one is the smallest number of form which is greater than , let's call it :
It remains to return the closest one to of these two numbers. Really easy task.