Is there any algorithm for this problem? because I am trying to code as per the problem.

I know below code is wrong and not efficient. please help me if any algorithm is there behind this.

myCode:

#include <stdio.h>

#include<math.h>

int main(void) {

// your code goes here

int n,t;

scanf("%d",&n);

while(n–){

int count=0,count1,sum=0,price,j=0,finalCount;

scanf("%d",&t);

for(int i=pow(2,j);j<=12;i=pow(2,++j)){

while(price<=t){

```
while(1){
sum=sum+i;
count++;
if(sum>=t){
price=sum;
sum = 0;
count1=count;
count=0;
break;
}
}
}
if(price == t){
if(count1<count){
finalCount = count1;
}else if(count1>count){
finalCount = count;
}
}
}
}
// printf("%d\n",finalCount);
}
return 0;
```

}