You just simply need to perform this procedure no more than 10000 times and at each step update the maximal profit and optimal number of times to get it if needed. Also note that after 10000 times we definitely obtain some amount of money that we had before and hence after that we can’t obtain better profit than earlier so it follows that for any input data the answer is not greater than 10000. The last sentence of the output specification was added just to make the problem trivial. In fact the maximal answer is less than 200.
if anyone wants to know how the maximum attempts are 10000 it is because of pigeon hole principle as you can have 100 dollar and 100 cent so all possible combination will be 10000 if you do this transformation more then that you will end in the same state as in one of the previous attempts. the maximal profit is limited to 200 because 100 dollar +100 cent is the maximum you can get (i know what i have written is 101 dollar but it proves the bound ).