The Logic of the code is that we have to find the minimum number of meals that the pretty girl can eat with a price exactly equals p now in the code first we are taking the test cases and thereafter we run the loop till test cases becomes zero and after that we start the loop from 2048 and goes uptil 0(not considering 0).
What is the logic behind doing so??
This is inorder to make sure that she eats minimum number of dishes now if we start from the minimum prices then she would end up eating huge number of dishes .
finally inside the loop we are counting the number of dishes the logic is that
think of it if i > p then count would remain zero finally when p > i we start incrementing the count and subsequently p would become the remainder p = p % i. Finally we print the answer.
TIme complexity:O(Log(N)) per test cases
i think so
Hope this answers your query
do ping me for any doubts.