Help me in solving CIELRCPT problem

My issue

can anyone please explalin this problem

My code

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner sc=new Scanner(System.in);
	    int t=sc.nextInt();
	    while(t-->0)
	    {
	        int p = sc.nextInt();
		    int count=0;
		    for(int i=11;i>=0;i--){
		        int x = (int)Math.pow(2,i);
		        while(x<=p){
		            count++;
		            p-=x;
		        }
		    }
		    System.out.println(count);
	    }
	}
}

Problem Link: CIELRCPT Problem - CodeChef

Here, the girl wants to find min. number of menus(orders) she would need to get exactly a bill of price p . Also here, in the menu, all the prices are given in powers of 2 as 2^0=1 , 2^1=2, 2^2=4 and so on… up to 2^11=2048. So, in order to get min. number of orders she will start checking from order with max. value which is 2^11=2048 which justifies why the for loop is in reverse. Now if 2^i<=p then to get value of new p we would subtract the price of that order from total price of bill p which she wants to achieve. And with each order the count is increased by value 1 if 2^i<=p. Hope this solves your query.