I wanted to give a complete answer for this question for future reference. There are a few concepts here that may be causing you issues and I want to make sure future readers understand how to implement this code.
When dealing with floats (As you do in this problem) its a good idea to assume only a certain level of precision, however you CAN assume this level of precision.
What you do in the above example is to simply multiply a float by 100 (Which is syntactically correct) but you never cast it to an int meaning its still just as imprecise. You should use an explicit cast and also ensure your fixing any inherent issues with the round() function.
Additionally you have some unneeded code in your problem where you are only executing if x >= q, well this is fine its not needed as the logic will still work otherwise. if x is too small to be divided it will just return 0 from the division and its value for the Modulus. If you where doing more then these actions it might be worth the check but in the current situation its not really needed.